static private string ConvertToIFCGuid(System.Guid guid)
        {
            byte[] byteArray = guid.ToByteArray();
            ulong[] num = new ulong[6];  
            num[0] = byteArray[3]; 
            num[1] = byteArray[2] * (ulong) 65536 + byteArray[1] * (ulong) 256 + byteArray[0];
            num[2] = byteArray[5] * (ulong) 65536 + byteArray[4] * (ulong) 256 + byteArray[7];
            num[3] = byteArray[6] * (ulong) 65536 + byteArray[8] * (ulong) 256 + byteArray[9];
            num[4] = byteArray[10] * (ulong) 65536 + byteArray[11] * (ulong) 256 + byteArray[12];
            num[5] = byteArray[13] * (ulong) 65536 + byteArray[14] * (ulong) 256 + byteArray[15];

            char[] buf = new char[22];
            int offset = 0;
        
            for (int ii = 0; ii < 6; ii++) 
            {
                int len = (ii == 0) ? 2 : 4;
                for (int jj = 0; jj < len; jj++) 
                {
                    buf[offset + len - jj - 1] = s_ConversionTable_2X[(int)(num[ii] % 64)];
                    num[ii] /= 64;
                }
                offset += len;
            }

            return new string(buf);
        }
Example #2
0
		public static System.Guid XOR(System.Guid guidA, System.Guid guidB)
		{
			var tmpRezArray = new byte[16];
			
			var tmpArrA = guidA.ToByteArray();
			
			var tmpArrB = guidB.ToByteArray();
			
			for(int n = 0; n < 16; n++)
			{
				tmpRezArray[n] = (byte)(tmpArrA[n] ^ tmpArrB[n]);
			}
		
			return new System.Guid(tmpRezArray);
		}
Example #3
0
 /// <summary> 
 /// 从 SQL SERVER 返回的 GUID 中生成时间信息 
 /// </summary> 
 /// <param name="guid">包含时间信息的 COMB </param> 
 /// <returns>时间</returns> 
 public static DateTime GetDateFromComb(System.Guid guid)
 {
     DateTime baseDate = new DateTime(1900, 1, 1);
     byte[] daysArray = new byte[4];
     byte[] msecsArray = new byte[4];
     byte[] guidArray = guid.ToByteArray();
     // Copy the date parts of the guid to the respective byte arrays.
     Array.Copy(guidArray, guidArray.Length - 6, daysArray, 2, 2);
     Array.Copy(guidArray, guidArray.Length - 4, msecsArray, 0, 4);
     // Reverse the arrays to put them into the appropriate order
     Array.Reverse(daysArray);
     Array.Reverse(msecsArray);
     // Convert the bytes to ints
     int days = BitConverter.ToInt32(daysArray, 0);
     int msecs = BitConverter.ToInt32(msecsArray, 0);
     DateTime date = baseDate.AddDays(days);
     date = date.AddMilliseconds(msecs * 3.333333);
     return date;
 }
        public static System.DateTime GetDateFromSequentialGuid(System.Guid guid)
        {
            System.DateTime baseDate = new System.DateTime(BASE_YEAR, BASE_MONTH, BASE_DAY);
            byte[] daysArray = new byte[4];
            byte[] msecsArray = new byte[4];
            byte[] guidArray = guid.ToByteArray();

            // Copy the date parts of the guid to the respective byte arrays
            System.Array.Copy(guidArray, guidArray.Length - 6, daysArray, 2, 2);
            System.Array.Copy(guidArray, guidArray.Length - 4, msecsArray, 0, 4);

            // Reverse the arrays to put them into the original order
            System.Array.Reverse(daysArray);
            System.Array.Reverse(msecsArray);

            // Convert the bytes to ints
            int days = System.BitConverter.ToInt32(daysArray, 0);
            int msecs = System.BitConverter.ToInt32(msecsArray, 0);

            System.DateTime date = baseDate.AddDays(days);
            date = date.AddMilliseconds(msecs * LIMITING_DIVISOR);

            return date;
        }
Example #5
0
        static Microsoft.Exchange.WebServices.Data.FolderId exchCreateFolder(ExchangeService service, string fldrDisplayName, Microsoft.Exchange.WebServices.Data.FolderId fldrParentID, ExtendedPropertyDefinition fldrRetentionPolicyTag, System.Guid fldrRetentionPolicyGUID, ExtendedPropertyDefinition fldrRetentionFlagTag, int fldrRetentionFlagValue)
        {
            // Verify that the paramters passed in are valid
            if (fldrDisplayName.Length == 0)
            {
                Console.WriteLine("\tError in exchCreateFolder : Invalid Folder Name");
                return null;
            }

            //Generate process output
            Console.Write("\tCreating Folder : " + fldrDisplayName + "...");

            if (service == null)
            {
                Console.WriteLine("error:Exchange Service reference Invalid");
                return null;
            }
            if (fldrParentID == null)
            {
                Console.WriteLine("error:Invalid Parent Folder");
                return null;
            }
            //if (fldrRetentionPolicyTag == null)
            //{
            //    Console.WriteLine("\t\tError in exchCreateFolder : Invalid Retention Policy Tag");
            //    return null;
            //}
            //if (fldrRetentionPolicyGUID == null)
            //{
            //    Console.WriteLine("\tError in exchCreateFolder : Invalid Retention Policy GUID");
            //    return null;
            //}

            //if (fldrRetentionFlagTag == null)
            //{
            //    Console.WriteLine("\t\tError in exchCreateFolder : Invalid Retention Policy Flag Tag");
            //    return null;
            //}

            //if (fldrRetentionFlagValue < 1)
            //{
            //    Console.WriteLine("\t\tError in exchCreateFolder : Invalid Retention Policy Flag Value");
            //    return null;
            //}

            //We have all of the inforamtion we need to make folders, create folder and assign retention policy.

            // Create Folder instance
            Folder newFolder = new Folder(service);

            try
            {
                // Assign attributes to folder and save it to exchange server
                newFolder.DisplayName = fldrDisplayName;
                if (fldrRetentionPolicyTag != null)
                {
                    Console.Write("Applying Retention Policy Tag..");
                    newFolder.SetExtendedProperty(fldrRetentionPolicyTag, fldrRetentionPolicyGUID.ToByteArray());
                    newFolder.SetExtendedProperty(fldrRetentionFlagTag, fldrRetentionFlagValue);

                }
                newFolder.Save(fldrParentID);

            }
            catch (Exception ex)
            {
                Console.WriteLine("Error : " + ex.Message);
                return null;

            }

            Console.WriteLine("success.");
            //Return the folder id reference
            return newFolder.Id;
        }
 void IUnityData.SetData(System.IO.Stream data, Object[] refs)
 {
     _data = data.ToByteArray();
     _unityObjectReferences = refs ?? new UnityEngine.Object[] { };
 }
Example #7
0
            private static BigInteger DecodeBigInteger(System.Numerics.BigInteger v)
            {
                var bytes = v.ToByteArray();

                if (bytes[bytes.Length - 1] == 0 && (bytes[bytes.Length - 2] & 128) != 0)
                    Array.Resize(ref bytes, bytes.Length - 1);

                Array.Reverse(bytes);

                return new BigInteger(bytes);
            }
Example #8
0
 public override SqlStatement GetLiteral(System.Guid guid)
 {
     return GetLiteralBinary(guid.ToByteArray());
 }
Example #9
0
 public static string Encode(System.Guid guid)
 {
     string base64String = Convert.ToBase64String(guid.ToByteArray());
     base64String = base64String.Replace("/", "_").Replace("+", "-");
     return base64String.Substring(0, 22);
 }
Example #10
0
 public override object FromGuid(System.Guid value, ConvertSetting convertSetting)
 {
     return convertSetting.Converter.ToDecimal(value.ToByteArray());
 }
Example #11
0
 /// <summary>Returns the Base64 version of the given guid.</summary>
 public static string ToBase64(System.Guid guid)
 {
     byte[] guidByteArray = guid.ToByteArray();
     return Convert.ToBase64String(guidByteArray);
 }