示例#1
0
        // Generates a KeyMapping from text.
        public static KeyMapping ReadMapping(string mapText)
        {
            var keyMap  = new KeyMapping();
            var entries = mapText.Split(new string[] { "\r\n" }, StringSplitOptions.None);

            foreach (var entry in entries)
            {
                var trimmedEntry = entry.Trim('[', ']', ' ');
                var pair         = trimmedEntry.Split(',');
                if (!Enum.TryParse(pair[0], out Key key) || Enum.TryParse(pair[2], out CommandType commandType))
                {
                    continue;
                }

                var dir = string.IsNullOrWhiteSpace(pair[1]) ? DefaultSkipName : pair[1];
                keyMap.Add(key, (new DirectoryInfo(dir), commandType));
            }

            return(keyMap);
        }
示例#2
0
        private void InferProperties()
        {
            ParentNavigationProperty =
                (from p in ParentContainer.BaseType.Properties.OfType <ResourceProperty>()
                 where p.IsNavigation && p.OtherAssociationEnd.ResourceType == ChildContainer.BaseType
                 select p).FirstOrDefault();

            AstoriaTestLog.Compare(ParentNavigationProperty != null,
                                   "Failed to identify parent navigation property");

            // figure out keymapping
            // each property in the key of the parent and child COULD be a local or foreign key
            // if it is a foreign key, then it could point to

            foreach (ResourceProperty c_prop in ChildContainer.BaseType.Key.Properties.Cast <ResourceProperty>())
            {
                ResourceProperty c_foreign = GetReferencedProperty(c_prop);
                foreach (ResourceProperty p_prop in ParentContainer.BaseType.Key.Properties.Cast <ResourceProperty>())
                {
                    ResourceProperty p_foreign = GetReferencedProperty(p_prop);
                    if (c_foreign == p_foreign)
                    {
                        KeyMapping.Add(p_prop.Name, c_prop.Name);
                        break;
                    }
                }
            }

            //AccessPathAttribute(string parentEntitySetName,
            //                    string parentNavigationPropertyName,
            //                    string childEntitySetName,
            //                    string parentKeys,
            //                    string childKeys)
            this.orderedParams.Add(String.Format("\"{0}\"", ParentContainer.Name));
            this.orderedParams.Add(String.Format("\"{0}\"", ParentNavigationProperty.Name));
            this.orderedParams.Add(String.Format("\"{0}\"", ChildContainer.Name));
            this.orderedParams.Add(String.Format("\"{0}\"", String.Join(",", KeyMapping.Keys.ToArray())));
            this.orderedParams.Add(String.Format("\"{0}\"", String.Join(",", KeyMapping.Values.ToArray())));
        }