Пример #1
0
        public override bool Equals(object obj)
        {
            PropertyReference propertyReference = obj as PropertyReference;

            return(propertyReference != null && (this.TargetId == propertyReference.TargetId && this.TargetDeleted == propertyReference.TargetDeleted && this.TargetObjectClass == propertyReference.TargetObjectClass) && this.TargetADObjectId == propertyReference.TargetADObjectId);
        }
Пример #2
0
 private static object ConvertSingleValueForDirectoryProperty(SyncPropertyDefinition property, object value)
 {
     if (object.Equals(property.DefaultValue, value) && !property.PersistDefaultValue)
     {
         return(SyncValueConvertor.IgnoreValue);
     }
     if (value == null)
     {
         return(null);
     }
     if (typeof(DirectoryPropertyString).IsAssignableFrom(property.ExternalType) || property.ExternalType == typeof(string))
     {
         return(ADValueConvertor.ConvertValueToString(value, property.FormatProvider));
     }
     if (typeof(DirectoryPropertyGuid).IsAssignableFrom(property.ExternalType))
     {
         return(ADValueConvertor.ConvertValueToString(value, property.FormatProvider));
     }
     if (typeof(DirectoryPropertyBinary).IsAssignableFrom(property.ExternalType))
     {
         return(ADValueConvertor.ConvertValueToBinary(value, property.FormatProvider));
     }
     if (typeof(DirectoryPropertyBoolean).IsAssignableFrom(property.ExternalType))
     {
         return(bool.Parse(ADValueConvertor.ConvertValueToString(value, property.FormatProvider)));
     }
     if (typeof(DirectoryPropertyInt32).IsAssignableFrom(property.ExternalType))
     {
         return(int.Parse(ADValueConvertor.ConvertValueToString(value, property.FormatProvider)));
     }
     if (typeof(DirectoryPropertyDateTime).IsAssignableFrom(property.ExternalType))
     {
         Type type = value.GetType();
         if (type.Equals(typeof(DateTime)))
         {
             return(((DateTime)value).ToUniversalTime());
         }
         return(DateTime.Parse(ADValueConvertor.ConvertValueToString(value, property.FormatProvider), property.FormatProvider));
     }
     else
     {
         if (typeof(DirectoryPropertyXmlServiceOriginatedResource) == property.ExternalType && value is Capability)
         {
             Capability capability = (Capability)value;
             if (CapabilityHelper.IsAllowedSKUCapability(capability))
             {
                 Guid skucapabilityGuid = CapabilityHelper.GetSKUCapabilityGuid(capability);
                 if (skucapabilityGuid != Guid.Empty)
                 {
                     return(new XmlValueServiceOriginatedResource
                     {
                         Resource = new ServiceOriginatedResourceValue
                         {
                             ServicePlanId = skucapabilityGuid.ToString("D"),
                             Capability = capability.ToString()
                         }
                     });
                 }
             }
             return(SyncValueConvertor.IgnoreValue);
         }
         if (typeof(DirectoryPropertyXmlDirSyncStatus).IsAssignableFrom(property.ExternalType))
         {
             string stringValue = (string)value;
             return(new XmlValueDirSyncStatus
             {
                 DirSyncStatus = SyncValueConvertor.ConvertStringToDirSyncStatus(stringValue)
             });
         }
         if (typeof(DirectoryPropertyReferenceAddressList).IsAssignableFrom(property.ExternalType) && value is PropertyReference)
         {
             PropertyReference propertyReference = (PropertyReference)value;
             return(new DirectoryReferenceAddressList
             {
                 TargetClass = propertyReference.TargetObjectClass,
                 Value = propertyReference.TargetId,
                 TargetDeleted = propertyReference.TargetDeleted
             });
         }
         throw new NotSupportedException("Conversion for external type " + property.ExternalType.Name);
     }
 }