[Adapdev-commits] Adapdev/src/Adapdev/UID GuidUIDGenerator.cs,1.4,1.5 TimeSpanUIDGenerator.cs,1.4,1.
Status: Beta
Brought to you by:
intesar66
From: Sean M. <int...@us...> - 2005-11-16 07:19:59
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev/UID In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4187/src/Adapdev/UID Added Files: GuidUIDGenerator.cs TimeSpanUIDGenerator.cs UIDFactory.cs UIDGenerator.cs Log Message: --- NEW FILE: UIDFactory.cs --- #region Copyright / License Information /* Copyright 2004 - 2005 Adapdev Technologies, LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ============================ Author Log ============================ III Full Name SMM Sean McCormack (Adapdev) ============================ Change Log ============================ III MMDDYY Change */ #endregion namespace Adapdev.UID { /// <summary> /// Summary description for UIDFactory. /// </summary> public class UIDFactory { private static UIDType t = UIDType.TimeSpan; private static string domain = "ABC"; private static bool showDomain = true; private UIDFactory() { } public static object GetNextId() { return GetNextId(t, showDomain); } public static object GetNextId(UIDType uidType) { return GetNextId(t, false); } public static object GetNextId(UIDType uidType, bool appendDomain) { object id; switch (uidType) { case UIDType.TimeSpan: id = TimeSpanUIDGenerator.GetInstance().GetNextId(); break; case UIDType.Guid: id = GuidUIDGenerator.GetInstance().GetNextId(); break; default: id = TimeSpanUIDGenerator.GetInstance().GetNextId(); break; } if (appendDomain) { id = domain + id; } return id; } public static UIDType Type { get { return UIDFactory.t; } set { UIDFactory.t = value; } } public static string Domain { get { return domain; } set { domain = value; } } public static bool AppendDomain { get { return showDomain; } set { showDomain = value; } } } public enum UIDType { TimeSpan, Guid } } --- NEW FILE: UIDGenerator.cs --- #region Copyright / License Information /* Copyright 2004 - 2005 Adapdev Technologies, LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ============================ Author Log ============================ III Full Name SMM Sean McCormack (Adapdev) ============================ Change Log ============================ III MMDDYY Change */ #endregion namespace Adapdev.UID { /// <summary> /// Summary description for OIDGenerator. /// </summary> public abstract class UIDGenerator { protected UIDGenerator() { } public abstract object GetNextId(); } } --- NEW FILE: GuidUIDGenerator.cs --- #region Copyright / License Information /* Copyright 2004 - 2005 Adapdev Technologies, LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ============================ Author Log ============================ III Full Name SMM Sean McCormack (Adapdev) ============================ Change Log ============================ III MMDDYY Change */ #endregion namespace Adapdev.UID { using System; /// <summary> /// Summary description for GuidUIDGenerator. /// </summary> public class GuidUIDGenerator : UIDGenerator { private static GuidUIDGenerator instance; private GuidUIDGenerator() : base() { } public static GuidUIDGenerator GetInstance() { if (instance == null) { instance = new GuidUIDGenerator(); } return instance; } public override object GetNextId() { return Guid.NewGuid(); } } } --- NEW FILE: TimeSpanUIDGenerator.cs --- #region Copyright / License Information /* Copyright 2004 - 2005 Adapdev Technologies, LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ============================ Author Log ============================ III Full Name SMM Sean McCormack (Adapdev) ============================ Change Log ============================ III MMDDYY Change */ #endregion namespace Adapdev.UID { using System; /// <summary> /// Summary description for TimeSpanOIDGenerator. /// </summary> public class TimeSpanUIDGenerator : UIDGenerator { private static TimeSpanUIDGenerator instance; private long id = 0; private TimeSpanUIDGenerator() : base() { id = DateTime.Now.Ticks; } public static TimeSpanUIDGenerator GetInstance() { if (instance == null) { instance = new TimeSpanUIDGenerator(); } return instance; } public override object GetNextId() { return id++; } } } |