SetID() публичный статический Метод

public static SetID ( System.Xml.Linq.XElement &xe ) : System.Guid
xe System.Xml.Linq.XElement
Результат System.Guid
Пример #1
0
        private XElement AddServiceAction(StringBuilder serviceData, List <DynamicServiceObjectBase> result, XElement xe, DynamicService ds, XElement action)
        {
            var sa = new ServiceAction {
                Name = action.AttributeSafe("Name"), ResourceDefinition = serviceData
            };

            // Set service action ;)
            var typeOf = action.AttributeSafe("Type");

            if (Enum.TryParse(typeOf, out enActionType actionType))
            {
                sa.ActionType = actionType;
            }

            var element = action.Element("Outputs");

            if (element != null)
            {
                sa.OutputSpecification = element.Value;
            }

            // set name and id ;)
            sa.ServiceName = ds.Name;
            var id = ServiceMetaData.SetID(ref xe);

            ds.ID = id;

            if (IsWorkflow(serviceData))
            {
                // Convert to StringBuilder
                var xElement = action.Element("XamlDefinition");
                if (xElement != null)
                {
                    var def = xElement.ToStringBuilder();
                    def = def.Replace("<XamlDefinition>", "").Replace("</XamlDefinition>", "");
                    sa.XamlDefinition = def.Unescape();
                }

                var dataList = xe.Element("DataList");
                if (dataList != null)
                {
                    ds.DataListSpecification = dataList.ToStringBuilder();
                }
            }
            else
            {
                sa = AddServiceAction(sa, action);
            }

            // add the action
            ds.Actions.Add(sa);
            result.Add(ds);
            return(xe);
        }
Пример #2
0
        public List <DynamicServiceObjectBase> GenerateServiceGraph(StringBuilder serviceData)
        {
            if (serviceData == null || serviceData.Length == 0)
            {
                throw new ArgumentException("serviceData");
            }
            var result = new List <DynamicServiceObjectBase>();
            var xe     = serviceData.ToXElement();

            if (IsSource(serviceData))
            {
                var src = new Source();
                var tmp = src as DynamicServiceObjectBase;
                ServiceMetaData.ExtractMetaData(xe, ref tmp);

                var typeOf = xe.AttributeSafe("ResourceType");

                src.Type = !Enum.TryParse(typeOf, out enSourceType sourceType) ? enSourceType.Unknown : sourceType;

                src.ConnectionString = xe.AttributeSafe("ConnectionString");
                src.AssemblyName     = xe.AttributeSafe("AssemblyName");
                src.AssemblyLocation = xe.AttributeSafe("AssemblyLocation");

                // PBI 6597: TWR - added source ID check
                var id = ServiceMetaData.SetID(ref xe);
                src.ID = id;
                src.ResourceDefinition = serviceData;

                result.Add(src);
            }
            else
            {
                var ds  = new DynamicService();
                var tmp = ds as DynamicServiceObjectBase;
                ServiceMetaData.ExtractMetaData(xe, ref tmp);

                // set the resource def ;)
                ds.ResourceDefinition = serviceData;

                var actions = xe.Element("Actions");
                var action  = actions != null?actions.Element("Action") : xe.Element("Action");

                if (action != null)
                {
                    xe = AddServiceAction(serviceData, result, xe, ds, action);
                }
            }
            return(result);
        }
Пример #3
0
        public List <DynamicServiceObjectBase> GenerateServiceGraph(StringBuilder serviceData)
        {
            if (serviceData == null || serviceData.Length == 0)
            {
                throw new ArgumentException("serviceData");
            }

            List <DynamicServiceObjectBase> result = new List <DynamicServiceObjectBase>();
            var xe = serviceData.ToXElement();

            if (IsSource(serviceData))
            {
                Source src = new Source();
                var    tmp = src as DynamicServiceObjectBase;
                ServiceMetaData.ExtractMetaData(xe, ref tmp);

                var typeOf = xe.AttributeSafe("ResourceType");

                enSourceType sourceType;
                src.Type = !Enum.TryParse(typeOf, out sourceType) ? enSourceType.Unknown : sourceType;

                src.ConnectionString = xe.AttributeSafe("ConnectionString");
                var tmpUri = xe.AttributeSafe("Uri");
                if (!string.IsNullOrEmpty(tmpUri))
                {
                    src.WebServiceUri = new Uri(tmpUri);
                }

                src.AssemblyName     = xe.AttributeSafe("AssemblyName");
                src.AssemblyLocation = xe.AttributeSafe("AssemblyLocation");

                // PBI 6597: TWR - added source ID check
                var id = ServiceMetaData.SetID(ref xe);
                src.ID = id;
                src.ResourceDefinition = serviceData;

                result.Add(src);
            }
            else
            {
                DynamicService ds  = new DynamicService();
                var            tmp = ds as DynamicServiceObjectBase;
                ServiceMetaData.ExtractMetaData(xe, ref tmp);

                // set the resource def ;)
                ds.ResourceDefinition = serviceData;

                var      actions = xe.Element("Actions");
                XElement action  = actions != null?actions.Element("Action") : xe.Element("Action");

                if (action != null)
                {
                    ServiceAction sa = new ServiceAction {
                        Name = action.AttributeSafe("Name"), ResourceDefinition = serviceData
                    };

                    // Set service action ;)
                    enActionType actionType;
                    var          typeOf = action.AttributeSafe("Type");
                    if (Enum.TryParse(typeOf, out actionType))
                    {
                        sa.ActionType = actionType;
                    }

                    var element = action.Element("Outputs");
                    if (element != null)
                    {
                        sa.OutputSpecification = element.Value;
                    }

                    // set name and id ;)
                    sa.ServiceName = ds.Name;
                    var id = ServiceMetaData.SetID(ref xe);
                    ds.ID = id;

                    if (IsWorkflow(serviceData))
                    {
                        // Convert to StringBuilder
                        var xElement = action.Element("XamlDefinition");
                        if (xElement != null)
                        {
                            var def = xElement.ToStringBuilder();
                            def = def.Replace("<XamlDefinition>", "").Replace("</XamlDefinition>", "");
                            sa.XamlDefinition = def.Unescape();
                        }

                        var dataList = xe.Element("DataList");
                        if (dataList != null)
                        {
                            ds.DataListSpecification = dataList.ToStringBuilder();
                        }
                    }
                    else
                    {
                        if (sa.ActionType == enActionType.InvokeStoredProc)
                        {
                            int timeout;
                            Int32.TryParse(action.AttributeSafe("CommandTimeout"), out timeout);
                            sa.CommandTimeout = timeout;
                        }

                        var xElement = action.Element("OutputDescription");
                        if (xElement != null)
                        {
                            sa.OutputDescription = xElement.Value;
                        }

                        // process inputs and outputs ;)
                        var inputs = action.Element("Inputs");

                        if (inputs != null)
                        {
                            var inputCollection = inputs.Elements("Input");

                            foreach (var inputItem in inputCollection)
                            {
                                bool emptyToNull;
                                bool.TryParse(inputItem.AttributeSafe("EmptyToNull"), out emptyToNull);

                                ServiceActionInput sai = new ServiceActionInput
                                {
                                    Name         = inputItem.AttributeSafe("Name"),
                                    Source       = inputItem.AttributeSafe("Source"),
                                    DefaultValue = inputItem.AttributeSafe("DefaultValue"),
                                    EmptyToNull  = emptyToNull,
                                    NativeType   = inputItem.AttributeSafe("NativeType")
                                };

                                if (string.IsNullOrEmpty(sai.NativeType))
                                {
                                    sai.NativeType = "object";
                                }

                                // handle validators ;)
                                var validators = inputItem.Elements("Validator");
                                foreach (var validator in validators)
                                {
                                    Validator v = new Validator();

                                    enValidationType validatorType;
                                    v.ValidatorType = !Enum.TryParse(validator.AttributeSafe("Type"), out validatorType) ? enValidationType.Required : validatorType;

                                    sai.Validators.Add(v);
                                }

                                sa.ServiceActionInputs.Add(sai);
                            }
                        }
                    }

                    // add the action
                    ds.Actions.Add(sa);
                    result.Add(ds);
                }
            }

            return(result);
        }