コード例 #1
0
        public RetrieveAttributeResponse(XmlNode response)
        {
            XmlNode results = XmlHelper.SelectSingleNode(response,"Results");
            XmlNode metaData= XmlHelper.SelectSingleNode(results.FirstChild,"value");

            // Just serialise the option sets
            // Get the type
            string type = XmlHelper.GetAttributeValue(metaData, "i:type");
            switch (type)
            {
                case "c:PicklistAttributeMetadata":
                    AttributeMetadata = MetadataSerialiser.DeSerialisePicklistAttributeMetadata(new PicklistAttributeMetadata(), metaData);
                    break;
                // TODO: Add in more attributes types
            }
        }
コード例 #2
0
 public static AttributeMetadata DeSerialiseAttributeMetadata(AttributeMetadata item, XmlNode entity)
 {
     return item;
 }
コード例 #3
0
        public static AttributeMetadata DeSerialiseAttributeMetadata(AttributeMetadata item, XmlNode attribute)
        {
            // Get the attributemetadata

            foreach (XmlNode node in attribute.ChildNodes)
            {
                Dictionary<string, object> itemValues = (Dictionary<string, object>)(object)item;
                string localName = XmlHelper.GetLocalName(node);
                string fieldName = localName.Substr(0, 1).ToLowerCase() + localName.Substr(1);

                // Check nil and don't set the value to save time/space
                if (node.Attributes.Count == 1 && node.Attributes[0].Name == "i:nil")
                {
                    continue;
                }

                // Non Type Specific properties
                switch (localName)
                {
                    // String values
                    case "AttributeOf":
                    case "DeprecatedVersion":
                    case "EntityLogicalName":
                    case "LogicalName":
                    case "SchemaName":
                    case "CalculationOf":
                        itemValues[fieldName] = XmlHelper.GetNodeTextValue(node);
                        break;

                    // Bool values
                    case "CanBeSecuredForCreate":
                    case "CanBeSecuredForRead":
                    case "CanBeSecuredForUpdate":
                    case "CanModifyAdditionalSettings":
                    case "IsAuditEnabled":
                    case "IsCustomAttribute":
                    case "IsCustomizable":
                    case "IsManaged":
                    case "IsPrimaryId":
                    case "IsPrimaryName":
                    case "IsRenameable":
                    case "IsSecured":
                    case "IsValidForAdvancedFind":
                    case "IsValidForCreate":
                    case "IsValidForRead":
                    case "IsValidForUpdate":
                    case "DefaultValue":
                        itemValues[fieldName] = Attribute.DeSerialise(node, AttributeTypes.Boolean_);
                        break;

                    // Int Values
                    case "ColumnNumber":
                    case "Precision":
                    case "DefaultFormValue":
                    case "MaxLength":
                    case "PrecisionSource":
                        itemValues[fieldName] = Attribute.DeSerialise(node, AttributeTypes.Int_);
                        break;

                    // Label
                    case "Description":
                    case "DisplayName":
                        Label label = new Label();
                        itemValues[fieldName] = MetadataSerialiser.DeSerialiseLabel(label,node);
                        break;

                    //OptionSet
                    case "OptionSet":
                        OptionSetMetadata options= new OptionSetMetadata();
                        itemValues[fieldName] = MetadataSerialiser.DeSerialiseOptionSetMetadata(options, node);
                        break;

                    case "AttributeType":
                        item.AttributeType = (AttributeTypeCode)(object)XmlHelper.GetNodeTextValue(node);
                        break;
                    //Guid
                    // LinkedAttributeId

                    //AttributeRequiredLevel
                    //RequiredLevel

                    //DateTime
                    //MaxSupportedValue (DateTimeAttributeMetadata)
                    //MinSupportedValue (DateTimeAttributeMetadata)

                    //decimal
                    //MaxValue (DecimalAttributeMetadata)

                    //IntegerFormat
                    //Format

                    //string[]
                    //Targets

                }

                // Type sepcific attributes

                //Boolean
                //DefaultValue (OptionSetMetadata)

                //int
                // MaxValue (IntegerAttributeMetadata)
                // MinValue (IntegerAttributeMetadata)

                // StringFormat
                //Format (MemoAttributeMetadata,StringAttributeMetadata)

                //double
                //MaxValue (DoubleAttributeMetadata, MoneyAttributeMetadata)
                //MinValue (DoubleAttributeMetadata, MoneyAttributeMetadata)

                //DateTimeFormat
                //Format (DateTimeAttributeMetadata)

                //long
                //MaxValue (BigIntAttributeMetadata)
                //MinValue (BigIntAttributeMetadata)

            }
            return item;
        }
コード例 #4
0
        public static EntityMetadata DeSerialiseEntityMetadata(EntityMetadata item, XmlNode entity)
        {
            foreach (XmlNode node in entity.ChildNodes)
            {
                Dictionary<string,object> itemValues = (Dictionary<string,object>)(object)item;
                string localName = XmlHelper.GetLocalName(node);
                string fieldName = localName.Substr(0,1).ToLowerCase() + localName.Substr(1); // This converts to camel case so we can use the import types from script#

                // Check nil and don't set the value to save time/space
                if (node.Attributes.Count == 1 && node.Attributes[0].Name == "i:nil")
                {
                    continue;
                }
                switch (localName)
                {
                        // String values
                    case "IconLargeName":
                    case "IconMediumName":
                    case "IconSmallName":
                    case "LogicalName":
                    case "PrimaryIdAttribute":
                    case "PrimaryNameAttribute":
                    case "RecurrenceBaseEntityLogicalName":
                    case "ReportViewName":
                    case "SchemaName":
                        itemValues[fieldName] = XmlHelper.GetNodeTextValue(node);
                        break;

                    // Bool values
                    case "AutoRouteToOwnerQueue":
                    case "CanBeInManyToMany":
                    case "CanBePrimaryEntityInRelationship":
                    case "CanBeRelatedEntityInRelationship":
                    case "CanCreateAttributes":
                    case "CanCreateCharts":
                    case "CanCreateForms":
                    case "CanCreateViews":
                    case "CanModifyAdditionalSettings":
                    case "CanTriggerWorkflow":
                    case "IsActivity":
                    case "IsActivityParty":
                    case "IsAuditEnabled":
                    case "IsAvailableOffline":
                    case "IsChildEntity":
                    case "IsConnectionsEnabled":
                    case "IsCustomEntity":
                    case "IsCustomizable":
                    case "IsDocumentManagementEnabled":
                    case "IsDuplicateDetectionEnabled":
                    case "IsEnabledForCharts":
                    case "IsImportable":
                    case "IsIntersect":
                    case "IsMailMergeEnabled":
                    case "IsManaged":
                    case "IsReadingPaneEnabled":
                    case "IsRenameable":
                    case "IsValidForAdvancedFind":
                    case "IsValidForQueue":
                    case "IsVisibleInMobile":
                        itemValues[fieldName] = Attribute.DeSerialise(node,AttributeTypes.Boolean_);
                        break;

                        // Int Values
                    case "ActivityTypeMask":
                    case "ObjectTypeCode":
                        itemValues[fieldName] = Attribute.DeSerialise(node, AttributeTypes.Int_);
                        break;

                    case "Attributes":
                        item.Attributes = new List<AttributeMetadata>();
                        foreach (XmlNode childNode in node.ChildNodes)
                        {
                            AttributeMetadata a = new AttributeMetadata();
                            item.Attributes.Add(MetadataSerialiser.DeSerialiseAttributeMetadata(a, childNode));

                        }
                        break;

                    ////Label
                    case "Description":
                    case "DisplayCollectionName":
                    case "DisplayName":
                        Label label = new Label();
                        itemValues[fieldName] = MetadataSerialiser.DeSerialiseLabel(label, node);
                        break;

                }

            }
            return item;
        }