Esempio n. 1
0
 internal SubPart(Part overridingPart, RepositoryWrapper repo)
 {
     _repository = repo;
     _previous = _repository.PartOverride;
     _override = overridingPart;
     _repository.PartOverride = _override;
 }
Esempio n. 2
0
 internal SubPart(String subPart, RepositoryWrapper repo)
 {
     _repository = repo;
     _previous = _repository.PartOverride;
     _override = new Part(subPart, repo.Part);
     _repository.PartOverride = _override;
 }
Esempio n. 3
0
 internal SubPart(Part overridingPart, RepositoryWrapper repo, TagBuilder wrappingTag, HtmlHelper helper)
 {
     _repository = repo;
     _previous = _repository.PartOverride;
     _override = overridingPart;
     _repository.PartOverride = _override;
     _wrappingTag = wrappingTag;
     _helper = helper;
     helper.ViewContext.Writer.WriteLine(wrappingTag.ToString(TagRenderMode.StartTag));
 }
 public MvcPartProvider(Part defaultPart)
 {
     _defaultPart = defaultPart;
 }
        private GroupNode GetOrCreateGroupNode(Part part)
        {
            var partString = part.ToString();
            if (_groups.ContainsKey(partString))
                return _groups[partString];

            var hierarchy = part.StackHierarchy();

            GroupNode node = null;
            foreach (var hierarchyPart in hierarchy) {
                var hierarchyPartString = hierarchyPart.ToString();
                if (_groups.ContainsKey(hierarchyPartString))
                    node = _groups[hierarchyPartString];
                else {
                    node = new GroupNode(hierarchyPart.Name, node);
                    _groups.Add(hierarchyPartString, node);
                }
            }
            return node;
        }
            public DBPart Insert(Part part, Connector connector)
            {
                var connection = connector.Connection;
                if (connection.State != ConnectionState.Open)
                    connection.Open();

                var partsToCreate = new List<Part>();
                while (part != null && GetPart(part.ToString()) == null)
                {
                    partsToCreate.Add(part);
                    part = part.Parent;
                }
                partsToCreate.Reverse();

                var command = new SqlCommand(String.Format(
                        "delete from {0} where {1} = @name and {2} = @parentId; insert into {0}({1}, {2}) values(@name, @parentId); select IDENT_CURRENT('{0}')",
                        _table, NameColumn, ParentIdColumn
                    ), connection
                );

                var lastCreatedPartId = part == null ? null : ((int?)GetPart(part.ToString()).Id);
                var lastCreatedPart = lastCreatedPartId == null ? null : _partsById[lastCreatedPartId.Value];
                foreach(var partToCreate in partsToCreate)
                {
                    command.Parameters.Clear();

                    command.Parameters.Add(new SqlParameter("name", SqlDbType.VarChar) { Value = partToCreate.Name });
                    command.Parameters.Add(new SqlParameter("parentId", SqlDbType.BigInt) { Value = (Object)lastCreatedPartId ?? DBNull.Value });

                    var newPart = new DBPart(Int32.Parse(command.ExecuteScalar().ToString()), partToCreate.Name, lastCreatedPart);
                    _partsById.Add(newPart.Id, newPart);
                    _partsByQualifier.Add(newPart.ToString().ToLower(), newPart);
                    lastCreatedPart = newPart;
                }

                return lastCreatedPart;
            }
 private Part GetSegmentPart(Part part)
 {
     return ABSegment == null ? part : new Part(ABSegment, part);
 }
Esempio n. 8
0
 public Qualifier(Part part, Locale locale, string key)
 {
     Part = part;
     Locale = locale;
     Key = key;
 }
Esempio n. 9
0
 public PartNode(Part part, bool isRoot)
 {
     Part = part;
     SubParts = new List<PartNode>();
     IsRoot = isRoot;
 }
 /// <summary>
 /// Make localization for qualified lookup in javascript.
 /// </summary>
 /// <param name="part">The part for lookup in the localization</param>
 /// <param name="locale">The locale for lookup in the localization</param>
 /// <param name="key">The key to look up in the localization</param>
 public LocalizedJavascriptContainer Add(Part part, Locale locale, String key)
 {
     var qualifiedValue = _repository.GetQualified(part, locale, key);
     _localization.AddIndirectValue(qualifiedValue);
     _qualifiedValuesWithReplacements.Add(
         Tuple.Create(
             qualifiedValue,
             new List<KeyValuePair<string, string>>()
         )
     );
     return this;
 }
 private static KeyValuePair<Qualifier.Unique, QualifiedValue> CreateValuePair(Part part, string key, string value)
 {
     var qualifier = new Qualifier.Unique(part, Locale, key);
     var qualifiedValue = new QualifiedValue(qualifier, new Value(ContentType.Text, value));
     return new KeyValuePair<Qualifier.Unique, QualifiedValue>(qualifier, qualifiedValue);
 }
Esempio n. 12
0
        private static void FixTree(IDictionary<Part, LocalizedPart> groupedParts, Part key)
        {
            var newKey = key.Parent;
            if (newKey == null || groupedParts.ContainsKey(newKey)) return;

            groupedParts.Add(newKey, new LocalizedPart(newKey, new List<QualifiedLocalization>(0)));
            FixTree(groupedParts, newKey);
        }
 public void DeleteLocalizationsFor(Part part, String key)
 {
     using (var connection = Connect()) {
         var partId = _partTable.GetPart(part.ToString()).Id;
         foreach (var locale in _localeTable.GetAll())
             _valueTable.Delete(new InternalQualifier(partId, locale.Id, key), connection);
     }
 }
Esempio n. 14
0
 /// <summary>
 /// Parses a part to parts with parent parts from a given string using the Separator, then puts this part under the given parent.
 /// </summary>
 /// <param name="part">String representation of the part</param>
 /// <param name="parentPart">Part of which this part will be a child</param>
 /// <returns></returns>
 public static Part Parse(String part, Part parentPart)
 {
     var parsed = Parse(part);
     parsed.Root.Parent = parentPart;
     return parsed;
 }
Esempio n. 15
0
 /// <summary>
 /// Creates a new part based on the name and its parent
 /// </summary>
 /// <param name="name">Name of the part</param>
 /// <param name="parent">Part of which this part will be a child</param>
 public Part(String name, Part parent)
     : this(name)
 {
     Parent = parent;
 }
Esempio n. 16
0
 public bool Equals(Part other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return Equals(other.Parent, Parent) && Equals(other.Name, Name);
 }
Esempio n. 17
0
 public LocalizedPart(Part part, List<QualifiedLocalization> localizations)
 {
     Part = part;
     Localizations = localizations;
     Subparts = new List<LocalizedPart>();
 }
 public DBPart(long id, String name, Part parent)
     : base(name, parent)
 {
     Id = id;
 }
 public void DeleteLocalizationsFor(Part part, String key)
 {
     foreach(var localization in _groups[part.ToString()].GetAllQualified().Where(qv => qv.Qualifier.Key == key).ToArray())
         DeleteValue(localization.Qualifier);
 }
 public RepositoryWrapper(LocalizationRepository repo, Part partOverride, String abSegment = null)
 {
     InnerRepository = repo;
     PartOverride = partOverride;
     ABSegment = abSegment;
 }
 public void DeleteLocalizationsFor(Part part, string key)
 {
     var valuesToDelete = AllValues.Where(kvp => Equals(kvp.Key.Part, part) && kvp.Key.Key == key).ToArray();
     foreach (var value in valuesToDelete)
         AllValues.Remove(value.Key);
 }
 public RepositoryWrapper(RepositoryWrapper repository, Part part, String abSegment = null)
 {
     PartOverride = part;
     ABSegment = abSegment;
     InnerRepository = repository.InnerRepository;
 }
Esempio n. 23
0
 public WithKey(String key, Part part)
 {
     if (String.IsNullOrEmpty(key))
         throw new ArgumentException("Key should not be Null or empty!", "key");
     Key = key;
     Part = part;
 }
 public String Get(Part part, Locale locale, String key, String defaultValue = null)
 {
     return InnerRepository.Get(new Qualifier.Unique(GetSegmentPart(part), locale, key), defaultValue);
 }
Esempio n. 25
0
            public Unique(Part part, Locale locale, String key)
                : base(key)
            {
                if(String.IsNullOrEmpty(key))
                    throw new ArgumentException("Key should not be Null or empty!", "key");
                if(part == null)
                    throw new ArgumentException("Part should not be Null!", "part");
                if (locale == null)
                    throw new ArgumentException("Locale should not be Null!", "locale");

                Part = part;
                Locale = locale;
            }
 public QualifiedValue GetQualified(Part part, Locale locale, String key, String defaultValue = null)
 {
     var value = InnerRepository.GetQualified(new Qualifier.Unique(GetSegmentPart(part), locale, key), defaultValue);
     return value;
 }
 public void DeleteLocalizationsFor(Part part, String key)
 {
     Reload(_connector.DeleteLocalizationsFor(part, key));
 }
 public ConstantPartProvider(Part part)
 {
     _part = part;
 }