Ejemplo n.º 1
0
        public XNodeValidator(XmlSchemaSet schemas, ValidationEventHandler validationEventHandler)
        {
            this.schemas = schemas;
            this.validationEventHandler = validationEventHandler;

            XNamespace xsi = XNamespace.Get("http://www.w3.org/2001/XMLSchema-instance");

            xsiTypeName = xsi.GetName("type");
            xsiNilName  = xsi.GetName("nil");
        }
Ejemplo n.º 2
0
        private static string GetVsixManifestVersion()
        {
            XDocument  vsixManifest = XDocument.Load(VsixManifestFileName);
            XNamespace ns           = vsixManifest.Root?.Name.Namespace ?? XNamespace.None;
            XElement   manifestRoot = vsixManifest.Element(ns.GetName("PackageManifest"));
            XElement   metadata     = manifestRoot?.Element(ns.GetName("Metadata"));
            XElement   identity     = metadata?.Element(ns.GetName("Identity"));

            return(identity?.Attribute("Version")?.Value);
        }
Ejemplo n.º 3
0
        public YouTubeVideo(XNamespace atomns, XElement entry, XNamespace medians)
        {
            var id = entry.Element(atomns.GetName("id")) != null && entry.Element(atomns.GetName("id")).Value != null
                ? entry.Element(atomns.GetName("id")).Value.Split(':').Last()
                : string.Empty;

            VideoUrl      = "http://gdata.youtube.com/feeds/api/videos/" + id;
            VideoImageUrl = (from thumbnail in entry.Descendants(medians.GetName("thumbnail"))
                             select thumbnail.Attribute("url").Value).FirstOrDefault();
            Title = entry.Element(atomns.GetName("title")) != null
                ? entry.Element(atomns.GetName("title")).Value
                : string.Empty;

            Summary = entry.Element(atomns.GetName("summary")) != null
                ? entry.Element(atomns.GetName("summary")).Value
                : string.Empty;

            if (string.IsNullOrEmpty(Summary))
            {
                Summary = entry.Element(atomns.GetName("content")) != null
                    ? entry.Element(atomns.GetName("content")).Value
                    : string.Empty;
            }
            if (string.IsNullOrEmpty(Summary))
            {
                Summary = Title;
            }
        }
        /// <summary>Initializes a new <see cref="XNodeSchemaApplier"/> instance.</summary>
        /// <param name="schemas">Schemas to use to predict elements and attributes.</param>
        private XNodeSchemaApplier(XmlSchemaSet schemas)
        {
            Debug.Assert(schemas != null, "schemas != null");

            this.schemas = schemas;
            XNamespace xsi = XNamespace.Get("http://www.w3.org/2001/XMLSchema-instance");

            this.xsiTypeName      = xsi.GetName("type");
            this.xsiNilName       = xsi.GetName("nil");
            this.namespaceManager = new XmlNamespaceManager(schemas.NameTable);
        }
        private DateTime GetPublishDate(XNamespace atoms, XElement entry)
        {
            DateTime publish = DateTime.MinValue;

            if (entry.Element(atoms.GetName("published")) != null && entry.Element(atoms.GetName("published")).Value != null)
            {
                DateTime.TryParse(entry.Element(atoms.GetName("published")).Value, out publish);
            }

            return(publish);
        }
        private string GetYouTubeTitle(XNamespace atoms, XElement entry, XNamespace medians)
        {
            string title = string.Empty;

            if (entry.Element(atoms.GetName("title")) != null)
            {
                title = entry.Element(atoms.GetName("title")).Value;
            }

            return(title);
        }
Ejemplo n.º 7
0
        public EnglishWord(XElement elem)
        {
            doc = XDocument.Load(@"xml\dataFiles\lessons.xml");
            xn  = doc.Root.Name.Namespace;

            LettersBigShape   = elem.Attribute("lettersBigShape").Value;
            LettersSmallShape = elem.Attribute("lettersSmallShape").Value;
            Word            = elem.Attribute("word").Value;
            WordPictuer     = new BitmapImage(new Uri(elem.Element(xn.GetName("wordPictuer")).Value));
            WordSound       = elem.Element(xn.GetName("wordSound")).Value;
            WordPictuerUsed = false;
        }
        internal static void UpdateFilesInModule(SPElementDefinition elementDefinition, SPWeb web)
        {
            XElement   xml        = elementDefinition.XmlDefinition.ToXElement();
            XNamespace xmlns      = "http://schemas.microsoft.com/sharepoint/";
            string     featureDir = elementDefinition.FeatureDefinition.RootDirectory;
            Module     module     = (from m in xml.DescendantsAndSelf()
                                     select new Module
            {
                ProvisioningUrl = m.Attribute("Url").Value,
                //PhysicalPath = Path.Combine(featureDir, m.Attribute("Path").Value),
                Files = (from f in m.Elements(xmlns.GetName("File"))
                         select new Module.File
                {
                    Name = f.Attribute("Url").Value,
                    PhysicalPath = Path.Combine(featureDir, f.Attribute("Path").Value),
                    Properties = (from p in f.Elements(xmlns.GetName("Property"))
                                  select p).ToDictionary(
                        n => n.Attribute("Name").Value,
                        v => v.Attribute("Value").Value)
                }).ToArray()
            }).First();

            if (module == null)
            {
                return;
            }

            foreach (Module.File file in module.Files)
            {
                string physicalPath = file.PhysicalPath;
                string virtualPath  = string.Concat(web.Url, "/", module.ProvisioningUrl, "/", file.Name);

                if (File.Exists(physicalPath))
                {
                    using (StreamReader sreader = new StreamReader(physicalPath))
                    {
                        if (!CheckOutStatus(web.GetFile(virtualPath)))
                        {
                            web.GetFile(virtualPath).CheckOut();
                        }
                        SPFile spFile = web.Files.Add(virtualPath, sreader.BaseStream, new Hashtable(file.Properties), true);
                        spFile.CheckIn("Updated", SPCheckinType.MajorCheckIn);
                        if (CheckContentApproval(spFile.Item))
                        {
                            spFile.Approve("Updated");
                        }

                        spFile.Update();
                    }
                }
            }
        }
        private XObject GenerateRecordExpression(XNamespace ns, IEdmRecordExpression record)
        {
            var recordElement = new XElement(ns.GetName("Record"));

            foreach (var property in record.Properties)
            {
                var propertyValueElement = new XElement(ns.GetName("PropertyValue"));
                propertyValueElement.Add(new XAttribute("Property", property.Name));
                propertyValueElement.Add(GenerateValueExpression(ns, property.Value));
                recordElement.Add(propertyValueElement);
            }
            return(recordElement);
        }
Ejemplo n.º 10
0
        private static void ReadId(XElement classElement, XNamespace ns, MappingModel model)
        {
            var idElement = classElement.Element(ns.GetName("id"));
            var idInfo    = new IdInfo();

            idInfo.ColumnName = idElement.Attribute("column")?.Value;
            idInfo.Name       = idElement.Attribute("name").Value;

            var stringGenerator = idElement.Element(ns.GetName("generator"))?.Attribute("class")?.Value;

            switch (stringGenerator)
            {
            case "guid.comb":
                idInfo.Generator = "Generators.GuidComb";
                break;

            case "assigned":
                idInfo.Generator = "Generators.Assigned";
                break;

            case "identity":
                idInfo.Generator = "Generators.Identity";
                break;

            case "native":
                idInfo.Generator = "Generators.Native";
                break;
            }

            if (idElement.Attribute("access")?.Value != null)
            {
                var xmlAccess = idElement.Attribute("access").Value;
                switch (xmlAccess.ToLower())
                {
                case "property":
                    idInfo.Access = "Accessor.Property";
                    break;

                case "field.camelcase-underscore":
                    idInfo.Access = "Accessor.Field";
                    break;
                }
            }

            idInfo.UnsavedValue = idElement.Attribute("unsaved-value")?.Value;
            if (idInfo.UnsavedValue == Guid.Empty.ToString())
            {
                idInfo.UnsavedValue = "System.Guid.Empty";
            }
            model.Id = idInfo;
        }
 /// <summary>
 /// Write inner values to persitance store
 /// </summary>
 /// <param name="readWriteValues"></param>
 /// <param name="writeOnlyValues"></param>
 protected override void CollectValues(out IDictionary <System.Xml.Linq.XName, object> readWriteValues, out IDictionary <System.Xml.Linq.XName, object> writeOnlyValues)
 {
     readWriteValues = new Dictionary <XName, object>
     {
         { ExtensionNamespace.GetName(NameName), _name },
         { ExtensionNamespace.GetName(IdName), _id },
         { ExtensionNamespace.GetName(DateName), _date }
     };
     writeOnlyValues = null;
 }
        /// <summary>
        /// Collect endpoint.
        /// </summary>
        /// <param name="collectRequest">collect request instance object.</param>
        /// <returns>redirect information instance object.</returns>
        public override RedirectInformation Collect(CollectRequest collectRequest)
        {
            XmlDocument response = new XmlDocument();
            XmlDocument payload  = JsonConvert.DeserializeXmlNode(collectRequest.ToJsonObject().ToString(), "payload");
            XElement    body     = new XElement(wsdl.GetName("collect"), XElement.Parse(payload.InnerXml));

            response.LoadXml(MakeRequest(body));
            response = RemoveNullFields(response);

            XmlNode data = response.SelectSingleNode("descendant::collectResult");
            JObject json = JObject.Parse(JsonConvert.SerializeXmlNode(data));

            return(new RedirectInformation(json.GetValue("collectResult").ToString()));
        }
        private string GetVideoUrl(XNamespace yt, XElement entry)
        {
            string videoUrl = string.Empty;
            string id       = string.Empty;

            if (entry.Element(yt.GetName("videoid")) != null && entry.Element(yt.GetName("videoid")).Value != null)
            {
                id = entry.Element(yt.GetName("videoid")).Value.Split(':').Last();
            }

            videoUrl = String.Format(CultureInfo.InvariantCulture, "http://gdata.youtube.com/feeds/api/videos/{0}", id);

            return(videoUrl);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Converts a Wix element.
        /// </summary>
        /// <param name="element">The Wix element to convert.</param>
        /// <returns>The converted element.</returns>
        private void ConvertWixElementWithoutNamespace(XElement element)
        {
            if (this.OnError(ConverterTestType.XmlnsMissing, element, "The xmlns attribute is missing.  It must be present with a value of '{0}'.", WixNamespace.NamespaceName))
            {
                element.Name = WixNamespace.GetName(element.Name.LocalName);

                element.Add(new XAttribute("xmlns", WixNamespace.NamespaceName)); // set the default namespace.

                foreach (XElement elementWithoutNamespace in element.Elements().Where(e => XNamespace.None == e.Name.Namespace))
                {
                    elementWithoutNamespace.Name = WixNamespace.GetName(elementWithoutNamespace.Name.LocalName);
                }
            }
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Moves <paramref name="element"/> into namespace <paramref name="newNamespace"/>.
 /// </summary>
 /// <param name="element">The element that will be moved into a new namespace.</param>
 /// <param name="newNamespace">The new namespace for the element.</param>
 public static void MoveToNamespace(this XElement element, XNamespace newNamespace)
 {
     foreach (XElement el in element.DescendantsAndSelf())
     {
         el.Name = newNamespace.GetName(el.Name.LocalName);
     }
 }
Ejemplo n.º 16
0
        public static Packet ConvertPacketFromXml(XElement xmlElement)
        {
            foreach (var el in xmlElement.DescendantsAndSelf())
            {
                var xAttribute = el.Attribute("xmlns");
                if (xAttribute != null)
                {
                    XNamespace aw = xAttribute.Value;

                    if (el.Name.Namespace != aw)
                    {
                        el.Name = aw.GetName(el.Name.LocalName);
                    }
                }
                else
                {
                    if (el.Parent != null)
                    {
                        el.Name = el.Parent.Name.Namespace.GetName(el.Name.LocalName);
                    }
                }
            }


            return(new Packet(xmlElement));
        }
Ejemplo n.º 17
0
        public letter(XElement elem) : this()
        {
            doc = XDocument.Load(@"xml\dataFiles\lessons.xml");
            xn  = doc.Root.Name.Namespace;

            ClipBig   = elem.Element(xn.GetName("clipBig")).Value;
            ClipSmall = elem.Element(xn.GetName("clipSmall")).Value;
            Sound     = elem.Element(xn.GetName("sound")).Value;
            Sound_BigletterExplanation   = elem.Element(xn.GetName("sound_BigLetterExplanation")).Value;
            Sound_smallletterExplanation = elem.Element(xn.GetName("sound_SmallLetterExplanation")).Value;
            LettersBigShape   = elem.Attribute("lettersBigShape").Value;
            LettersSmallShape = elem.Attribute("lettersSmallShape").Value;
            HebrewLetter      = elem.Attribute("hebrewLetter").Value;

            setWordsForLetter(LettersBigShape);
        }
        private XObject GenerateValueExpression(XNamespace ns, IEdmExpression expression)
        {
            // TODO: handle other than constant, other DataTypes
            XObject returnXObject = null;

            switch (expression.ExpressionKind)
            {
            case EdmExpressionKind.Null:
                returnXObject = new XElement(ns.GetName("Null"));
                break;

            case EdmExpressionKind.IntegerConstant:
                var integerConstantExpression = (IEdmIntegerConstantExpression)expression;
                returnXObject = new XAttribute("Int", integerConstantExpression.Value);
                break;

            case EdmExpressionKind.StringConstant:
                var stringConstantExpression = (IEdmStringConstantExpression)expression;
                returnXObject = new XAttribute("String", stringConstantExpression.Value);
                break;

            case EdmExpressionKind.Collection:
                returnXObject = this.GenerateCollectionExpression(ns, (IEdmCollectionExpression)expression);
                break;

            case EdmExpressionKind.Record:
                returnXObject = this.GenerateRecordExpression(ns, (IEdmRecordExpression)expression);
                break;

            default:
                throw new NotSupportedException();
            }
            return(returnXObject);
        }
Ejemplo n.º 19
0
        internal static XName GetXsiType(XElement xe)
        {
            string type = (string)xe.Attribute(XName.Get("type", XmlSchema.InstanceNamespace));

            if (type != null)
            {
                string     prefix    = string.Empty;
                string     localName = ParseQName(type, out prefix);
                XNamespace ns        = null;
                if (prefix.Length == 0)
                {
                    ns = xe.GetDefaultNamespace();
                }
                else
                {
                    ns = xe.GetNamespaceOfPrefix(prefix);
                }

                if (ns != null)
                {
                    return(ns.GetName(localName));
                }
                else
                {
                    return(XName.Get(localName));
                }
            }

            return(null);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// this METHOD should be commented, in release version!
        /// this is a helper method which can be used to create metadata xaml from data.linq entities
        /// this xaml can be later pasted as metadata in the user control
        /// and of course it needs to be corrected, but it is faster than to type all this from the start in code editor
        /// </summary>
        public override string ServiceGetXAML()
        {
            var        metadata = base.GetMetadata();
            var        xaml     = System.Windows.Markup.XamlWriter.Save(metadata);
            XNamespace data     = "clr-namespace:RIAPP.DataService;assembly=RIAPP.DataService";
            XNamespace dal      = "clr-namespace:RIAppDemo.DAL;assembly=RIAppDemo.DAL";

            XElement xtree = XElement.Parse(xaml);

            foreach (XElement el in xtree.DescendantsAndSelf())
            {
                el.Name = data.GetName(el.Name.LocalName);
                if (el.Name.LocalName == "Metadata")
                {
                    List <XAttribute> atList = el.Attributes().ToList();
                    el.Attributes().Remove();
                }
                else if (el.Name.LocalName == "DbSetInfo")
                {
                    XAttribute entityTypeAttr = el.Attributes().Where(a => a.Name.LocalName == "EntityType").First();
                    entityTypeAttr.Value = string.Format("{{x:Type {0}}}", entityTypeAttr.Value);
                }
            }
            xtree.Add(new XAttribute(XNamespace.Xmlns + "data", "clr-namespace:RIAPP.DataService;assembly=RIAPP.DataService"));
            return(xtree.ToString());
        }
Ejemplo n.º 21
0
        public HadLearnt(Lesson currentLesson)
        {
            doc = XDocument.Load(@"xml\dataFiles\lessons.xml");
            xn  = doc.Root.Name.Namespace;


            foreach (var lesson in  doc.Descendants(xn.GetName("lesson")))
            {
                if (int.Parse(lesson.Attribute("lessonCode").Value) <= int.Parse(currentLesson._lessonCode))
                {
                    lesson_learnt.Add(new Lesson(lesson.Attribute("lessonCode").Value));
                }
            }
            foreach (var lesson in lesson_learnt)
            {
                foreach (var letter in lesson.lettersForLesson)
                {
                    letterBigShape_HadLearnt.Add(letter.LettersBigShape);
                    letterSmallShape_HadLearnt.Add(letter.LettersSmallShape);
                    letters_HadLearnt.Add(letter);

                    foreach (var word in letter.wordsForLetter)
                    {
                        pictuers_HadLearnt.Add(word);
                    }
                }
            }
        }
Ejemplo n.º 22
0
        void ComparePackages(Action <Func <IEnumerable <XElement>, IEnumerable <object> >, Func <string, string> > compare)
        {
            compare(
                elements =>
            {
                XNamespace umlNamespace = elements.First().GetNamespaceOfPrefix("uml");
                XName umlPackage        = umlNamespace.GetName("Package");

                return(from p in elements
                       where (p.Name == "packagedElement" && GetXmiType(p) == "uml:Package") ||
                       p.Name == umlPackage
                       let Name = GetName(p)
                                  let ParentName = p.Parent != null ? GetName(p.Parent) : string.Empty
                                                   orderby ParentName, Name
                       select new
                {
                    Name,
                    Visibility = GetVisibility(p),
                    ParentName
                });
            },
                folderClause =>
            {
                return(string.Format(@"
                                select p1.Name, p2.Name as ParentName, p1.Visibility
                                from [Microsoft.Uml2].[Packages] as p1 left join
                                     [Microsoft.Uml2].[Packages] as p2 on p2.Id = p1.OwningPackage And p1.Folder = p2.Folder 
                                join [Microsoft.Uml2].[UmlResources] ur on ur.Id = p1.ResourceId 
				join [Microsoft.Uml2].[UmlResourceStems] us on ur.Stem = us.Id
                                where p1.ElementKind='Package' and p1.{0} -- and p1.IsReference='false' 
                                order by ParentName, p1.Name",
                                     folderClause));
            });
        }
Ejemplo n.º 23
0
//<Snippet1>
        static void Main(string[] args)
        {
            // Create service host.
            WorkflowServiceHost host = new WorkflowServiceHost(CountingWorkflow(), new Uri(hostBaseAddress));

            // Add service endpoint.
            host.AddServiceEndpoint("ICountingWorkflow", new BasicHttpBinding(), "");

            // Define SqlWorkflowInstanceStore and assign it to host.
            SqlWorkflowInstanceStoreBehavior store = new SqlWorkflowInstanceStoreBehavior(connectionString);
            List <XName> variantProperties         = new List <XName>()
            {
                xNS.GetName("Count")
            };

            store.Promote("CountStatus", variantProperties, null);

            host.Description.Behaviors.Add(store);

            host.WorkflowExtensions.Add <CounterStatus>(() => new CounterStatus());
            host.Open(); // This sample needs to be run with Admin privileges.
                         // Otherwise the channel listener is not allowed to open ports.
                         // See sample documentation for details.

            // Create a client that sends a message to create an instance of the workflow.
            ICountingWorkflow client = ChannelFactory <ICountingWorkflow> .CreateChannel(new BasicHttpBinding(), new EndpointAddress(hostBaseAddress));

            client.start();

            Console.WriteLine("(Press [Enter] at any time to terminate host)");
            Console.ReadLine();
            host.Close();
        }
        private static void SerializeXmlTree(XmlTreeAnnotation xmlTree, XElement parent)
        {
            ExceptionUtilities.CheckArgumentNotNull(xmlTree, "xmlTree");

            XNamespace targetNamespace = XNamespace.Get(xmlTree.NamespaceName);

            if (xmlTree.IsAttribute)
            {
                CreateAttribute(parent, xmlTree.LocalName, xmlTree.NamespaceName, xmlTree.PropertyValue);
            }
            else
            {
                XElement element = parent.Element(targetNamespace.GetName(xmlTree.LocalName));

                // create new element for repeatable elements
                if (element == null || IsRepeatableElement(element))
                {
                    element = CreateElement(parent, xmlTree.NamespacePrefix, xmlTree.LocalName, xmlTree.NamespaceName);
                }

                foreach (var child in xmlTree.Children)
                {
                    SerializeXmlTree(child, element);
                }

                if (xmlTree.PropertyValue != null)
                {
                    element.Value = xmlTree.PropertyValue;
                }
            }
        }
Ejemplo n.º 25
0
        // FIXME: our manifest merger is hacky.
        // To support complete manifest merger, we will have to implement fairly complicated one, described at
        // http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger
        void MergeLibraryManifest(string mergedManifest)
        {
            var nsResolver = new XmlNamespaceManager(new NameTable());

            nsResolver.AddNamespace("android", androidNs.NamespaceName);
            var xdoc    = XDocument.Load(mergedManifest);
            var package = xdoc.Root.Attribute("package")?.Value ?? string.Empty;

            foreach (var top in xdoc.XPathSelectElements("/manifest/*"))
            {
                var name     = top.Attribute(AndroidXmlNamespace.GetName("name"));
                var existing = (name != null) ?
                               doc.XPathSelectElement(string.Format("/manifest/{0}[@android:name='{1}']", top.Name.LocalName, name.Value), nsResolver) :
                               doc.XPathSelectElement(string.Format("/manifest/{0}", top.Name.LocalName));
                if (existing != null)
                {
                    // if there is existing node with the same android:name, then append contents to existing node.
                    existing.Add(FixupNameElements(package, top.Nodes()));
                }
                else
                {
                    // otherwise, just add to the doc.
                    doc.Root.Add(FixupNameElements(package, new XNode [] { top }));
                }
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="element">The element containing the node</param>
        //  Revision History
        //  MM/DD/YY who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------
        //  05/09/13 RCG 2.80.28 N/A    Created

        public PropertyNode(XElement element)
        {
            if (element != null && element.Name.LocalName == ELEMENT_NAME)
            {
                XNamespace NameSpace = element.GetDefaultNamespace();

                if (element.Attribute(ATTRIB_TYPE) != null)
                {
                    m_PropertyType = EnumDescriptionRetriever.ParseToEnum <PropertyNodeType>(element.Attribute(ATTRIB_TYPE).Value);
                }

                if (element.Attribute(ATTRIB_INDEX) != null)
                {
                    m_Index = sbyte.Parse(element.Attribute(ATTRIB_INDEX).Value);
                }

                m_Clients = new List <ClientNode>();

                foreach (XElement ClientElement in element.Descendants(NameSpace.GetName(ClientNode.ELEMENT_NAME)))
                {
                    m_Clients.Add(new ClientNode(ClientElement));
                }
            }
            else
            {
                throw new ArgumentException("Not a valid property element", "element");
            }
        }
Ejemplo n.º 27
0
        public static XElement XElementFromElastic(ElasticObject elastic, XNamespace nameSpace = null)
        {
            // we default to empty namespace
            nameSpace = nameSpace ?? string.Empty;
            var exp = new XElement(nameSpace + elastic.InternalName);

            foreach (var a in elastic.Attributes.Where(a => a.Value.InternalValue != null))
            {
                // if we have xmlns attribute add it like XNamespace instead of regular attribute
                if (a.Key.Equals("xmlns", StringComparison.InvariantCultureIgnoreCase))
                {
                    nameSpace = a.Value.InternalValue.ToString();
                    exp.Name  = nameSpace.GetName(exp.Name.LocalName);
                }
                else
                {
                    exp.Add(new XAttribute(a.Key, a.Value.InternalValue));
                }
            }

            if (elastic.InternalContent is string)
            {
                exp.Add(new XText(elastic.InternalContent as string));
            }

            foreach (var child in elastic.Elements.Select(c => XElementFromElastic(c, nameSpace)))
            {
                exp.Add(child);
            }

            return(exp);
        }
Ejemplo n.º 28
0
        IList <string> AddMonoRuntimeProviders(XElement app)
        {
            app.Add(CreateMonoRuntimeProvider("mono.MonoRuntimeProvider", null, --AppInitOrder));

            var providerNames = new List <string> ();

            var processAttrName = androidNs.GetName("process");
            var procs           = new List <string> ();

            foreach (XElement el in app.Elements())
            {
                var proc = el.Attribute(processAttrName);
                if (proc == null)
                {
                    continue;
                }
                if (procs.Contains(proc.Value))
                {
                    continue;
                }
                procs.Add(proc.Value);
                if (el.Name.NamespaceName != String.Empty)
                {
                    continue;
                }
                switch (el.Name.LocalName)
                {
                case "provider":
                    var autho = el.Attribute(androidNs.GetName("authorities"));
                    if (autho != null && autho.Value.EndsWith(".__mono_init__"))
                    {
                        continue;
                    }
                    goto case "activity";

                case "activity":
                case "receiver":
                case "service":
                    string providerName = "MonoRuntimeProvider_" + procs.Count;
                    providerNames.Add(providerName);
                    app.Add(CreateMonoRuntimeProvider("mono." + providerName, proc.Value, --AppInitOrder));
                    break;
                }
            }

            return(providerNames);
        }
Ejemplo n.º 29
0
        private CorrelationKey(string keyString, XNamespace provider) : base(GenerateKey(keyString), dictionary)
        {
            Dictionary <XName, InstanceValue> dictionary = new Dictionary <XName, InstanceValue>(2);

            dictionary.Add(provider.GetName("KeyString"), new InstanceValue(keyString, InstanceValueOptions.Optional));
            dictionary.Add(WorkflowNamespace.KeyProvider, new InstanceValue(provider.NamespaceName, InstanceValueOptions.Optional));
            this.KeyString = keyString;
        }
        private static XAttribute CreateAttribute(XElement parent, string localName, XNamespace xmlNamespace, object value)
        {
            XName name = xmlNamespace != null?xmlNamespace.GetName(localName) : localName;

            XAttribute attribute = new XAttribute(name, value);

            parent.Add(attribute);
            return(attribute);
        }