Example #1
0
        public ImapNamespaceDesc(string prefix, string hierarchyDelimiter, IDictionary<string, string[]> extensions)
        {
            if (prefix == null)
            throw new ArgumentNullException("prefix");
              if (extensions == null)
            throw new ArgumentNullException("extensions");

              this.Prefix = prefix;
              this.HierarchyDelimiter = hierarchyDelimiter;
              this.Extensions = extensions.AsReadOnly();
        }
        /// <summary>
        ///     Initializes a new instance of the <see cref="ExportDefinition"/> class with 
        ///     the specified contract name and metadata.
        /// </summary>
        /// <param name="contractName">
        ///     A <see cref="String"/> containing the contract name of the 
        ///     <see cref="ExportDefinition"/>.
        /// </param>
        /// <param name="metadata">
        ///     An <see cref="IDictionary{TKey, TValue}"/> containing the metadata of the 
        ///     <see cref="ExportDefinition"/>; or <see langword="null"/> to set the 
        ///     <see cref="Metadata"/> property to an empty, read-only 
        ///     <see cref="IDictionary{TKey, TValue}"/>.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="contractName"/> is <see langword="null"/>.
        /// </exception>
        /// <exception cref="ArgumentException">
        ///     <paramref name="contractName"/> is an empty string ("").
        /// </exception>
        public ExportDefinition(string contractName, IDictionary<string, object> metadata)
        {
            Requires.NotNullOrEmpty(contractName, "contractName");

            _contractName = contractName;

            if (metadata != null)
            {
                _metadata = metadata.AsReadOnly();
            }
        }
 public DerivedComposablePartDefinition(
     IDictionary<string, object> metadata,
     Func<ComposablePart> partCreator,
     Func<IEnumerable<ImportDefinition>> importsCreator,
     Func<IEnumerable<ExportDefinition>> exportsCreator)
 {
     this._metadata = metadata.AsReadOnly();
     this._partCreator = partCreator;
     this._importsCreator = importsCreator;
     this._exportsCreator = exportsCreator;
 }
        public FakeViewRow(IDictionary<string, object> info)
        {
            if (!info.TryGetValue("id", out _id))
            {
                _id = null;
            }

            object tempKey;
            if (!info.TryGetValue("key", out tempKey))
            {
                throw new InvalidOperationException("The value 'key' was not found in the info definition.");
            }

            _key = (tempKey as object[]) ?? (new[] { tempKey });
            _info = info.AsReadOnly();
        }
Example #5
0
        private static void GetDisallowedEntries( XmlNode node, int numSections, out IList<IList<int>> disallowed, out IList<IDictionary<int,string>> staticEntries )
        {
            IList<IList<int>> result = new IList<int>[numSections];
            IList<IDictionary<int, string>> ourStatic = new IDictionary<int, string>[numSections];
            XmlNode disallowedNode = node.SelectSingleNode( "DisallowedEntries" );
            if ( disallowedNode != null )
            {
                foreach ( XmlNode node2 in disallowedNode.SelectNodes( "Section" ) )
                {
                    int sec = Int32.Parse( node2.Attributes["value"].InnerText );
                    List<int> ourResult = new List<int>();
                    Dictionary<int, string> ourDict = new Dictionary<int, string>();
                    foreach ( XmlNode ent in node2.SelectNodes( "entry" ) )
                    {
                        int idx = Int32.Parse(ent.InnerText);
                        ourResult.Add( idx);
                        XmlAttribute stat = ent.Attributes["staticValue"];
                        if ( stat != null )
                        {
                            ourDict[idx] = stat.InnerText;
                        }
                        else
                        {
                            ourDict[idx] = string.Empty;
                        }
                    }
                    result[sec] = ourResult.AsReadOnly();
                    ourStatic[sec] = new ReadOnlyDictionary<int, string>( ourDict );
                }
            }
            for ( int i = 0; i < result.Count; i++ )
            {
                if ( result[i] == null )
                {
                    result[i] = new int[0].AsReadOnly();
                }
                if ( ourStatic[i] == null )
                {
                    ourStatic[i] = new ReadOnlyDictionary<int, string>( new Dictionary<int, string>( 0 ) );
                }
            }

            disallowed = result.AsReadOnly();
            staticEntries = ourStatic.AsReadOnly();
        }
Example #6
0
        public static Bug FromJsonObject(IDictionary<string, object> jsonObject)
        {
            jsonObject = jsonObject.WrapInMissingKeySafeDictionary ();
            var bug = new Bug ();

            try {
                bug.AssignedTo = (string) jsonObject["assigned_to"];
                bug.BlocksOn = ((JsonArray) jsonObject["blocks"]).Cast<long> ().ToArray ();
                bug.Classification = (string) jsonObject["classification"];
                bug.Component = (string) jsonObject["component"];
                bug.Creator = (string) jsonObject["creator"];
                bug.DependsOn = ((JsonArray) jsonObject["depends_on"]).Cast<long> ().ToArray ();
                bug.DuplicateOf = (long?) jsonObject["duplicate_of"];
                bug.Groups = ((JsonArray) jsonObject["groups"]).Cast<string> ().ToArray ();
                bug.Id = (long) jsonObject["id"];
                bug.Keywords = ((JsonArray) jsonObject["keywords"]).Cast<string> ().ToArray ();
                bug.LastChanged = DateTime.SpecifyKind (DateTime.Parse ((string) jsonObject["last_change_time"]), DateTimeKind.Utc);
                bug.Milestone = (string) jsonObject["target_milestone"];
                bug.Priority = (string) jsonObject["priority"];
                bug.Product = (string) jsonObject["product"];
                bug.Resolution = (string) jsonObject["resolution"];
                bug.SeeAlso = ((JsonArray) jsonObject["see_also"]).Cast<string> ().ToArray ();
                bug.Severity = (string) jsonObject["severity"];
                bug.Status = (string) jsonObject["status"];
                bug.Subscribers = ((JsonArray) jsonObject["cc"]).Cast<string> ().ToArray ();
                bug.Summary = (string) jsonObject["summary"];
                bug.Version = (string) jsonObject["version"];
                bug.Attributes = jsonObject.AsReadOnly ();
                bug.Url = (string) jsonObject["url"];
            } catch (Exception e) {
                #if DEBUG
                Console.Error.WriteLine(jsonObject.ToString());
                #endif
                Console.WriteLine("Failed to parse bug from JSON: {0}", e.Message);
            }
            return bug;
        }
Example #7
0
        public TermExpression(IDictionary<TermExpression, TermExpression> terms)
        {
            if (terms == null || terms.Count == 0)
                throw new CqlLinqException("Empty dictionaries are not allowed");

            var firstElement = terms.First();
            _type = typeof(IDictionary<,>).MakeGenericType(firstElement.Key.Type, firstElement.Value.Type);
            _dictionaryTerms = terms.AsReadOnly();
            _termType = CqlExpressionType.Map;
        }
Example #8
0
 private TermExpression(TermExpression original, IEnumerable<TermExpression> terms,
                        IDictionary<TermExpression, TermExpression> dictTerms)
 {
     _function = original.Function;
     _termType = original._termType;
     _type = original.Type;
     _value = original.Value;
     _terms = terms.AsReadOnly();
     _dictionaryTerms = dictTerms.AsReadOnly();
 }