示例#1
0
        public ColumnMapping(object anonymousType) :
            this()
        {
            foreach (var p in anonymousType.GetType().GetProperties())
            {
                var value = p.GetValue(anonymousType, null);
                var name  = p.Name.ToLower();

                if (name.EndsWith("enum") && value.GetType().BaseType == typeof(System.Enum))
                {
                    value = new Microsoft.Xrm.Sdk.OptionSetValue((int)value);
                    name  = name.Remove(name.Length - "enum".Length);
                }

                switch (name)
                {
                case "id":
                    base.Id = (System.Guid)value;
                    Attributes["columnmappingid"] = base.Id;
                    break;

                case "columnmappingid":
                    var id = (System.Nullable <System.Guid>)value;
                    if (id == null)
                    {
                        continue;
                    }
                    base.Id          = id.Value;
                    Attributes[name] = base.Id;
                    break;

                case "formattedvalues":
                    // Add Support for FormattedValues
                    FormattedValues.AddRange((Microsoft.Xrm.Sdk.FormattedValueCollection)value);
                    break;

                default:
                    Attributes[name] = value;
                    break;
                }
            }
        }
示例#2
0
 public PostComment(object anonymousType) :
     this()
 {
     foreach (var p in anonymousType.GetType().GetProperties())
     {
         var value = p.GetValue(anonymousType, null);
         if (p.PropertyType == typeof(System.Guid))
         {
             // Type is Guid, must be Id
             base.Id = (System.Guid)value;
             Attributes["postcommentid"] = base.Id;
         }
         else if (p.Name == "FormattedValues")
         {
             // Add Support for FormattedValues
             FormattedValues.AddRange((Microsoft.Xrm.Sdk.FormattedValueCollection)value);
         }
         else
         {
             Attributes[p.Name.ToLower()] = value;
         }
     }
 }
 public HierarchySecurityConfiguration(object anonymousType) :
     this()
 {
     foreach (var p in anonymousType.GetType().GetProperties())
     {
         var value = p.GetValue(anonymousType, null);
         if (p.PropertyType == typeof(System.Guid))
         {
             // Type is Guid, must be Id
             base.Id = (System.Guid)value;
             Attributes["hierarchysecuritymodelingsettingid"] = base.Id;
         }
         else if (p.Name == "FormattedValues")
         {
             // Add Support for FormattedValues
             FormattedValues.AddRange((Microsoft.Xrm.Sdk.FormattedValueCollection)value);
         }
         else
         {
             Attributes[p.Name.ToLower()] = value;
         }
     }
 }
示例#4
0
 public SdkMessageProcessingStepSecureConfig(object anonymousType) :
     this()
 {
     foreach (var p in anonymousType.GetType().GetProperties())
     {
         var value = p.GetValue(anonymousType, null);
         if (p.PropertyType == typeof(System.Guid))
         {
             // Type is Guid, must be Id
             base.Id = (System.Guid)value;
             Attributes["sdkmessageprocessingstepsecureconfigid"] = base.Id;
         }
         else if (p.Name == "FormattedValues")
         {
             // Add Support for FormattedValues
             FormattedValues.AddRange((Microsoft.Xrm.Sdk.FormattedValueCollection)value);
         }
         else
         {
             Attributes[p.Name.ToLower()] = value;
         }
     }
 }