Esempio n. 1
0
        private void ReportResults(IntegratorUser integratorUser, IHasId <Guid> jobPoster, Report report)
        {
            const string method = "ReportResults";

            _jobAdIntegrationReportsCommand.CreateJobAdIntegrationEvent(new JobAdImportPostEvent
            {
                Success          = true,
                IntegratorUserId = integratorUser.Id,
                PosterId         = jobPoster.Id,
                JobAds           = report.JobAds,
                Closed           = report.Closed,
                Duplicates       = report.Duplicates,
                Failed           = report.Failed,
                Posted           = report.Posted,
                Updated          = report.Updated,
                Ignored          = report.Ignored,
            });

            var message = string.Format("Processing complete. {0} job ads created, {1} updated,"
                                        + " {2} closed, {3} failed, {4} were ignored as duplicates of those from another source,"
                                        + " {5} were ignored as coming from the ignored source.",
                                        report.Posted, report.Updated, report.Closed, report.Failed, report.Duplicates, report.Ignored);

            _logger.Raise(Event.Information, method, message);
        }
Esempio n. 2
0
        private void SaveSearch(IHasId <Guid> employer, MemberSearchCriteria criteria, CandidatesResponseModel model, int page)
        {
            try
            {
                var userAgent = HttpContext.Request.UserAgent;

                //never log monitoring calls
                if (!string.IsNullOrEmpty(userAgent) && userAgent.Contains("LinkmeMonitoring"))
                {
                    return;
                }

                var app       = ActivityContext.Channel.App;
                var execution = new MemberSearchExecution
                {
                    Context  = "NewSearch",
                    Criteria = criteria.Clone(),
                    Results  = new MemberSearchResults
                    {
                        MemberIds    = page == 1 ? (from c in model.Candidates select c.Id).ToArray() : new Guid[0],
                        TotalMatches = model.TotalCandidates
                    },
                    SearcherId = employer == null ? (Guid?)null : employer.Id,
                    ChannelId  = app.ChannelId,
                    AppId      = app.Id,
                    StartTime  = DateTime.Now,
                };

                _memberSearchesCommand.CreateMemberSearchExecution(execution);
            }
            catch (Exception)
            {
                // Never fail for this.
            }
        }
Esempio n. 3
0
        private JobAdSortExecution Sort(IHasId <Guid> member, JobAdSearchSortCriteria sortCriteria, Range range, Func <IJobAdSortService, Guid?, JobAdSortQuery, JobAdSearchResults> sort)
        {
            var criteria = new JobAdSortCriteria {
                SortCriteria = sortCriteria
            };

            JobAdSearchResults results;
            var service = _serviceManager.Create();

            try
            {
                results = sort(service, member == null ? (Guid?)null : member.Id, criteria.GetSortQuery(range));
            }
            catch (Exception)
            {
                _serviceManager.Abort(service);
                throw;
            }
            _serviceManager.Close(service);

            return(new JobAdSortExecution
            {
                Criteria = criteria,
                Results = results,
            });
        }
Esempio n. 4
0
 protected void HasAccessToItemAndThrow(StoredItemAccessMode ruleType, IHasId storeItem, IUserInfoStore user)
 {
     if (!this.HasAccessToItem(ruleType, storeItem, user))
     {
         throw new StoreSecurityException(storeItem, user, ruleType);
     }
 }
Esempio n. 5
0
        private ResumeFileModel GetLastUsedResumeFile(IHasId <Guid> member)
        {
            if (member == null)
            {
                return(null);
            }
            var resumeFile = _candidateResumeFilesQuery.GetLastUsedResumeFile(member.Id);

            if (resumeFile == null)
            {
                return(null);
            }
            var fileReference = _filesQuery.GetFileReference(resumeFile.FileReferenceId);

            if (fileReference == null)
            {
                return(null);
            }

            return(new ResumeFileModel
            {
                FileReferenceId = resumeFile.FileReferenceId,
                FileName = fileReference.FileName,
            });
        }
Esempio n. 6
0
        private ResourceListModel <TResource> GetResourceListModel <TResource>(IHasId <Guid> user, ResourceListModel <TResource> model)
            where TResource : Resource
        {
            if (user is Member)
            {
                var candidate = _candidatesQuery.GetCandidate(user.Id);
                var resume    = candidate.ResumeId == null ? null : _resumesQuery.GetResume(candidate.ResumeId.Value);
                model.ResumePercentComplete = _memberStatusQuery.GetPercentComplete(CurrentMember, candidate, resume);
                model.HasResume             = HasResume(candidate);
            }
            else
            {
                model.ResumePercentComplete = 0;
                model.HasResume             = false;
            }

            model.TopRatedArticle = _resourcesQuery.GetTopRatedArticle();
            model.TopViewedQnA    = _resourcesQuery.GetTopViewedQnA();

            // Set the data for all resources in the model.

            model.Viewings        = GetViewings(model);
            model.LastViewedTimes = GetLastViewedTimes(model);
            model.Ratings         = GetRatings(user.Id, model);
            model.Comments        = GetComments(model);
            return(model);
        }
Esempio n. 7
0
        public void Build(object obj)
        {
            A4ormObject returnValue = new A4ormObject();

            if (obj is IHasId)
            {
                IHasId iHasId = obj as IHasId;
                returnValue.Id = iHasId.Id;
            }
            else
            {
                //autogen id
                returnValue.Id = Guid.NewGuid().ToString();
            }

            //walk the object
            var meta = TypeMetaCache.Instance.GetTypeMeta(obj.GetType());

            meta.Properties.WithEach(propMeta =>
            {
                A4ormProperty prop = new A4ormProperty();
                prop.Type          = propMeta.Type;
            });
            var inspector = ObjectInspectorCache.Instance.GetInspector(obj.GetType());



            return(returnValue);
        }
 public NamedValueIHasIdDecoration(IHasId decorated, string name, object val)
     : base(decorated)
 {
     Condition.Requires(name).IsNotNullOrEmpty();
     this.Name = name;
     this.Value = val;
 }
        /// <summary>
        /// Compares navigational properties of two models defined by a foreign key property. These nagivational properties must implement IHasId interface and cannot be lists and collections. TODO: improve this method so that an actual navigational property is selected, not its foreign key
        /// </summary>
        /// <typeparam name="TModel"></typeparam>
        /// <param name="model1"></param>
        /// <param name="model2"></param>
        /// <param name="foreignKey"></param>
        /// <returns></returns>
        public static bool CompareNagivationalProperties <TModel>(TModel model1, TModel model2, Expression <Func <TModel, int?> > foreignKey) where TModel : class
        {
            if (foreignKey == null)
            {
                throw new ArgumentNullException("foreignKey may not be null whereas it is null now");
            }
            MemberExpression    mex        = (MemberExpression)foreignKey.Body;
            PropertyInfo        fkProperty = (PropertyInfo)mex.Member;
            ForeignKeyAttribute attr       = fkProperty.GetCustomAttribute(typeof(ForeignKeyAttribute)) as ForeignKeyAttribute;

            if (attr == null)
            {
                throw new ArgumentException("foreignKey property does not contain ForeignKey attribute");
            }

            int?key1 = fkProperty.GetValue(model1) as int?;
            int?key2 = fkProperty.GetValue(model2) as int?;

            if (key1 != key2)
            {
                return(false);
            }
            else if (key1 == null && key2 == null)
            {
                PropertyInfo property = typeof(TModel).GetProperty(attr.Name);
                IHasId       val1     = property.GetValue(model1) as IHasId;
                IHasId       val2     = property.GetValue(model2) as IHasId;

                if (val1?.Id != val2?.Id)
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 10
0
        public static PolyfacingIHasIdDecoration <Tface> Polyfacing <Tface>(this IHasId decorated, Polyface rootFace = null)
            where Tface : IHasId
        {
            Condition.Requires(decorated).IsNotNull();

            PolyfacingIHasIdDecoration <Tface> rv = null;

            /*Summary:
             * if we spec a root we are setting that root
             * if the condition is already polyfacing we use that otherwise build new one
             * if no root is spec'd we create new polyface
             */

            //if we have polyface in our chain, we return that
            if (decorated.HasDecoration <PolyfacingIHasIdDecoration <Tface> >())
            {
                rv = decorated.FindDecoration <PolyfacingIHasIdDecoration <Tface> >();
            }
            else
            {
                rv = new PolyfacingIHasIdDecoration <Tface>(decorated, rootFace);
            }

            return(rv);
        }
Esempio n. 11
0
 public NamedValueIHasIdDecoration(IHasId decorated, string name, object val)
     : base(decorated)
 {
     Condition.Requires(name).IsNotNullOrEmpty();
     this.Name  = name;
     this.Value = val;
 }
Esempio n. 12
0
        private void CreateNewJobAd(string adContent, JobAdStatus adStatus, IHasId <Guid> adPoster,
                                    bool adHideContactDetails, ContactDetails adContactDetails, string summary, string bulletpoint1, string bulletpoint2,
                                    string bulletpoint3, FileReference logoImg, string adTitle, string positionTitle,
                                    JobTypes jobtypes, bool isResidenacyRequired, string externalRef, decimal?maxsalary,
                                    decimal?minsalary, string package, IList <Industry> reqIndustries, string companyname,
                                    LocationReference jobLocation, DateTime expiryDate)
        {
            var bulletPoints = new[] { bulletpoint1, bulletpoint2, bulletpoint3 };

            var newJobAd = new JobAd
            {
                Status     = adStatus,
                PosterId   = adPoster.Id,
                Visibility =
                {
                    HideContactDetails = adHideContactDetails,
                    HideCompany        = false,
                },
                ContactDetails = adContactDetails,
                Title          = adTitle,
                Integration    = { ExternalReferenceId = externalRef },
                LogoId         = logoImg == null ? (Guid?)null : logoImg.Id,
                ExpiryTime     = expiryDate,
                Description    =
                {
                    CompanyName       = companyname,
                    Content           = adContent,
                    PositionTitle     = positionTitle,
                    ResidencyRequired = isResidenacyRequired,
                    JobTypes          = jobtypes,
                    Industries        = reqIndustries,
                    Summary           = summary,
                    Salary            = (minsalary.HasValue || maxsalary.HasValue
                        ? new Salary
                    {
                        Currency      = Currency.AUD,
                        LowerBound    = minsalary,
                        UpperBound    = maxsalary,
                        Rate          = SalaryRate.Year,
                    }
                        : null),
                    Package      = package,
                    BulletPoints = bulletPoints,
                    Location     = jobLocation,
                }
            };

            _jobAdsCommand.CreateJobAd(newJobAd);

            if (adStatus == JobAdStatus.Open)
            {
                _jobAdsCommand.OpenJobAd(newJobAd);
            }
            else if (adStatus == JobAdStatus.Closed)
            {
                _jobAdsCommand.CloseJobAd(newJobAd);
            }

            return;
        }
Esempio n. 13
0
        public static string Dehydrate(IHasId obj)
        {
            var item = new SerializedIHasId(obj);
            var rv   = item.Dehydrate();

            return(rv);
        }
Esempio n. 14
0
        private JobAd CreateJobAd(IHasId <Guid> employer, JobAdStatus status)
        {
            var jobAd = new JobAd
            {
                Id          = Guid.NewGuid(),
                Status      = status,
                Title       = "Best Job in the World",
                CreatedTime = DateTime.Now,
                PosterId    = employer.Id,
                Description =
                {
                    BulletPoints = new[]               { "good verbal communication", "self management and independency", "bullet point 3" },
                    Content      = "Mutley, you snickering, floppy eared hound. When courage is needed, you're never around.",
                    JobTypes     = JobTypes.FullTime,
                    Industries   = new List <Industry> {
                        _industriesQuery.GetIndustry("Engineering")
                    },
                },
            };

            _jobAdsCommand.CreateJobAd(jobAd);
            _jobAdsCommand.OpenJobAd(jobAd);
            if (status == JobAdStatus.Closed)
            {
                _jobAdsCommand.CloseJobAd(jobAd);
            }
            return(jobAd);
        }
Esempio n. 15
0
 private static bool CanAccessSearch(IHasId <Guid> owner, MemberSearch search)
 {
     if (owner == null)
     {
         return(false);
     }
     return(owner.Id == search.OwnerId);
 }
Esempio n. 16
0
        public void SetIndex(IHasId obj)
        {
            Condition.Requires(obj).IsNotNull();

            var hasBits = this.IndexFactory.GenerateIndex(obj);
            var soid = obj.GetStoredObjectId();
            this._storeOfIndices.SaveItem(new IndexedEntry(soid.BuildAsId().HasBits(hasBits)));
        }
Esempio n. 17
0
        /// <summary>
        /// ctor takes an IHasId.  Kacks if it isn't.
        /// </summary>
        public StoredObjectId(IHasId iHasId)
        {
            Condition.Requires(iHasId).IsNotNull();

            //copy the id/type over
            this._objectId   = iHasId.Id;
            this._objectType = iHasId.GetType();
        }
Esempio n. 18
0
 public static PendingReadModelUpdate Create(IHasId source, PendingReadModelUpdateSourceCategory category)
 {
     if (source == null)
     {
         throw new ArgumentNullException(nameof(source));
     }
     return(Create(source.Id, category));
 }
Esempio n. 19
0
        private JobAd ApplyForExternalJob(IHasId <Guid> member)
        {
            var employer = CreateEmployer();
            var jobAd    = _jobAdsCommand.PostTestJobAd(employer);

            ApplyForExternalJob(member, jobAd);
            return(jobAd);
        }
Esempio n. 20
0
 private static bool CanAccess(IHasId <Guid> user, IJobAd entry)
 {
     if (user == null)
     {
         return(false);
     }
     return(user.Id == entry.PosterId);
 }
Esempio n. 21
0
 private static bool CanAccessList(IHasId <Guid> employer, ApplicantList applicantList)
 {
     if (employer == null || applicantList == null)
     {
         return(false);
     }
     return(employer.Id == applicantList.PosterId);
 }
Esempio n. 22
0
 private static bool CanAccessList(IHasId <Guid> employer, IJobAd jobAd)
 {
     if (employer == null || jobAd == null)
     {
         return(false);
     }
     return(employer.Id == jobAd.PosterId);
 }
Esempio n. 23
0
 public PolyfacingIHasIdDecoration(IHasId decorated, Polyface rootFace = null)
     : base(decorated)
 {
     //if no polyface is set we create new one
     this.RootFace = (rootFace == null) ? Polyface.New() : rootFace;
     //register the face
     this.RootFace.Is(typeof(Tface), this);
 }
Esempio n. 24
0
 public bool Equals(IHasId <T>?x, IHasId <T>?y)
 {
     if (x == null)
     {
         return(y == null);
     }
     return(y != null && EqualityComparer <T> .Default.Equals(x.Id, y.Id));
 }
Esempio n. 25
0
        public static IWriteableStore SaveItem(this IWriteableStore store, IHasId obj)
        {
            if (store == null)
                return store;

            store.Commit(CommitBag.New().MarkItemSaved(obj));
            return store;
        }
Esempio n. 26
0
 public StoreSecurityException(IHasId item, IUserInfoStore user, StoredItemAccessMode ruleType)
     : base(string.Format("{2} Access denied on {0} for {1}", item, user, ruleType))
 {
     Condition.Requires(item).IsNotNull();
     Condition.Requires(user).IsNotNull();
     this._item = item;
     this._user = user;
     this._ruleType = ruleType;
 }
Esempio n. 27
0
        private static int GetApplicationStatusCount(this IHasId <Guid> applicantList, IDictionary <Guid, IDictionary <ApplicantStatus, int> > counts, ApplicantStatus status)
        {
            if (applicantList == null || !counts.ContainsKey(applicantList.Id))
            {
                return(0);
            }

            return(counts[applicantList.Id][status]);
        }
Esempio n. 28
0
        public void SetIndex(IHasId obj)
        {
            Condition.Requires(obj).IsNotNull();

            var hasBits = this.IndexFactory.GenerateIndex(obj);
            var soid    = obj.GetStoredObjectId();

            this._storeOfIndices.SaveItem(new IndexedEntry(soid.BuildAsId().HasBits(hasBits)));
        }
Esempio n. 29
0
 public StoreSecurityException(IHasId item, IUserInfoStore user, StoredItemAccessMode ruleType)
     : base(string.Format("{2} Access denied on {0} for {1}", item, user, ruleType))
 {
     Condition.Requires(item).IsNotNull();
     Condition.Requires(user).IsNotNull();
     this._item     = item;
     this._user     = user;
     this._ruleType = ruleType;
 }
Esempio n. 30
0
        public static StoredObjectId GetStoredObjectId(this IHasId item)
        {
            if (item == null)
            {
                return(null);
            }

            return(new StoredObjectId(item));
        }
Esempio n. 31
0
        public static void SaveEvictingItem(this IEvictingStore store, IHasId obj, IExpirable evictingCondition)
        {
            if (store == null)
            {
                return;
            }

            store.Commit(new CommitBag().MarkItemSaved(obj), evictingCondition);
        }
Esempio n. 32
0
        private SerializedIHasId(IHasId obj)
        {
            Condition.Requires(obj).IsNotNull();

            var id = obj.GetStoredObjectId();

            this.Id      = _serializer.Serialize(id);
            this.Context = _serializer.Serialize(obj);
        }
Esempio n. 33
0
        private static bool CanUpdateNote(IHasId <Guid> employer, CandidateNote note)
        {
            // Must own the note to update it.

            if (employer == null || note == null)
            {
                return(false);
            }
            return(note.RecruiterId == employer.Id);
        }
Esempio n. 34
0
        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            // call base
            base.GetObjectData(info, context);

            //pull out added info
            this._item = info.GetValue("_item", typeof(object)) as IHasId;
            this._user = info.GetValue("_user", typeof( object)) as IUserInfoStore;
            this._ruleType = (StoredItemAccessMode)info.GetValue("_ruleType", typeof(StoredItemAccessMode));
        }
Esempio n. 35
0
        public async Task Scrobble(IHasId item)
        {
            using (var request = new HttpRequestMessage(HttpMethod.Get,
                                                        "/:/scrobble?identifier=com.plexapp.plugins.library&key=" + item.Id))
            {
                var resp = await _httpClient.SendAsync(request);

                var respStr = await resp.Content.ReadAsStringAsync();
            }
        }
Esempio n. 36
0
        /// <summary>
        /// returns a search filter that finds other objects that have the same id but not the same type
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static LogicOfTo<IHasId,bool> GetFindSameIdDiffTypeSearchFilter(IHasId obj)
        {
            LogicOfTo<IHasId, bool> filter = LogicOfTo<IHasId, bool>.New((item) =>
            {
                bool hasSameId = item.Id.Equals(obj.Id);
                bool isSameType = item.GetType().Equals(obj.GetType());
                return hasSameId && (!isSameType);
            });

            return filter;
        }
Esempio n. 37
0
        public static void SaveItemIfUniqueElseThrow(this IStore store, IHasId obj)
        {
            if (store == null)
                return;

            //throw if the item exists
            var dup = store.Get(obj.GetStoredObjectId());
            if (dup != null)
                throw new InvalidOperationException("Item already exists " + obj.Id.ToString());

            store.Commit(new CommitBag().MarkItemSaved(obj));
        }
        /// <summary>
        /// replaces an item with the same id
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="store"></param>
        /// <param name="item"></param>
        public static void Replace(this IStoreOfUniqueId store, IHasId newItem)
        {
            Condition.Requires(store).IsNotNull();
            if (newItem == null)
                return;

            //get the item with the same id
            var item = store.GetById(newItem.Id);
            store.DeleteItem(item.GetStoredObjectId());
            //commit the new item
            store.SaveItem(newItem);
        }
Esempio n. 39
0
        private IHasBits _hasBits; //uses backing field to wrap
        #endregion

        #region Ctor
        /// <summary>
        /// 
        /// </summary>
        /// <param name="decorated"></param>
        /// <param name="hasBits">if null will default to 32bit BitArrayHasBits instance</param>
        public HasBitsIHasIdDecoration(IHasId decorated, IHasBits hasBits = null)
            : base(decorated)
        {
            if (hasBits != null)
            {
                this._hasBits = hasBits;
            }
            else
            {
                this._hasBits = NaturalBitArrayHasBits.New(new BitArray(32));
            }
        }
Esempio n. 40
0
        public ICommitBag MarkItemSaved(IHasId obj)
        {
            if (obj == null) { return this; }

            //we don't allow StoredObjectIds...we have to be dealing with actual objects
            if (obj is StoredObjectId)
                throw new InvalidOperationException("StoredObjectId type is not allowed");

            lock (this._stateLock)
            {
                List<IHasId> list =  this.ItemsToSave as List<IHasId>;
                
                list.RemoveAll(x => StoredObjectId.New(x).Equals(StoredObjectId.New(obj)));

                this.ItemsToSave.Add(obj);
            }
            return this;
        }
 public override IDecorationOf<IHasId> ApplyThisDecorationTo(IHasId thing)
 {
     return new HasMachineNameDecoration(thing, this.MachineName);
 }
Esempio n. 42
0
 public override IDecorationOf<IHasId> ApplyThisDecorationTo(IHasId thing)
 {
     return new HasBitsIHasIdDecoration(thing, this._hasBits);
 }
Esempio n. 43
0
        /// <summary>
        /// for a particular stored item, accessing user, and access mode, get all applicable rules, in order of least 
        /// dependent rule to most
        /// </summary>
        /// <param name="ruleType"></param>
        /// <param name="storeItem"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        protected List<StoreAccessRule> GetItemRulesForUser(StoredItemAccessMode ruleType, IHasId storeItem, IUserInfoStore user)
        {
            //first look for item specific rules, and null item rules
            SearchFilterOf<StoreAccessRule> filter = new SearchFilterOf<StoreAccessRule>((x) =>
            {
                if (x.RuleType == ruleType &&
                    (x.Item == null || x.Item.Id.Equals(storeItem.Id)))
                    return true;

                return false;
            });

            var list = RuleStore.Search<StoreAccessRule>(filter);

            List<IHasDependencyOf<StoreAccessRule>> unsortedList = list.ConvertListTo<IHasDependencyOf<StoreAccessRule>, StoreAccessRule>();

            //now order the list by dependency from least to most
            var sortedList = DependencyUtil.SortHasADependency(unsortedList);

            //return
            var sortedConvertedList = sortedList.ConvertListTo<StoreAccessRule, IHasDependencyOf<StoreAccessRule>>();

            //add ALL overriding rules to the first on the list

            //RULE 1:  The owner will always have full access to item
            sortedConvertedList.Insert(0, new StoreAccessRule("OWNER", ruleType, (ihasId, accessUser) =>
            {
                if (accessUser.Id.Equals(user.Id))
                {
                    return true;
                }
                return null;
            }));

            return sortedConvertedList;
        }
Esempio n. 44
0
 public HasVersionDecoration(IHasId decorated, string version)
     : base(decorated)
 {
     Condition.Requires(version).IsNotNull();
     this.Version = version;
 }
Esempio n. 45
0
 public override IDecorationOf<IHasId> ApplyThisDecorationTo(IHasId thing)
 {
     return new StringableDecoration(thing);
 }
Esempio n. 46
0
 public DistributedId(IHasId decorated, DateTime dateCreated, Guid guid, string localMachine, IPAddress addr) 
     :base(decorated.HasDateCreated(dateCreated).HasGUID(guid).HasMachineName(localMachine).HasIP(addr))
 {
 }
Esempio n. 47
0
 public override IDecorationOf<IHasId> ApplyThisDecorationTo(IHasId thing)
 {
     return new HasVersionDecoration(thing, this.Version);
 }
 public override IDecorationOf<IHasId> ApplyThisDecorationTo(IHasId thing)
 {
     return new HasDateCreatedDecoration(thing, this.DateCreated);
 }
 public HasDateCreatedDecoration(IHasId decorated, DateTime dateCreated)
     : base(decorated)
 {
     this.DateCreated = dateCreated.ToUniversalTime();
 }
 public override IDecorationOf<IHasId> ApplyThisDecorationTo(IHasId thing)
 {
     return new ContextualIHasIdDecoration(thing, this.Context);
 }
Esempio n. 51
0
 public NamingIHasIdDecoration(IHasId decorated, string name)
     : base(decorated)
 {
     Condition.Requires(name).IsNotNullOrEmpty();
     this.Name = name;
 }
 public override IDecorationOf<IHasId> ApplyThisDecorationTo(IHasId thing)
 {
     return new NamedValueIHasIdDecoration(thing, this.Name, this.Value);
 }
Esempio n. 53
0
        public IHasBits GenerateIndex(IHasId obj)
        {
            //get all the bitlogic items
            var bitLogics = this.StoreOfBitLogic.GetAll().OrderBy(x => x.Id).ToArray();

            var rv = NaturalBitArrayHasBits.New(new BitArray(bitLogics.Length));

            //foreach item, position by position, set the hasbits values
            bitLogics.WithEach(x =>
            {
                var nameFace = x.As<IHasName>();
                var indexFace = x.As<IHasId<int>>();
                var logicFace = x.As<LogicOfTo<IHasId, bool>>();

                var logic = logicFace.Perform(obj) as LogicOfTo<IHasId, bool>;
                rv.SetBit(indexFace.Id, logic.Result);
            });

            return rv;
        }
 public HasMachineNameDecoration(IHasId decorated, string machineName)
     : base(decorated)
 {
     Condition.Requires(machineName).IsNotNull();
     this.MachineName = machineName;
 }
Esempio n. 55
0
 public override IDecorationOf<IHasId> ApplyThisDecorationTo(IHasId thing)
 {
     return new DistributedId(thing, this.DateCreated, this.GUID, this.MachineName, this.IPAddress);
 }
Esempio n. 56
0
 protected void HasAccessToItemAndThrow(StoredItemAccessMode ruleType, IHasId storeItem, IUserInfoStore user)
 {
     if (!this.HasAccessToItem(ruleType, storeItem, user))
     {
         throw new StoreSecurityException(storeItem, user, ruleType);
     }
 }
Esempio n. 57
0
        public StringableDecoration(IHasId decorated)
            : base(decorated)
        {

        }
Esempio n. 58
0
        protected bool HasAccessToItem(StoredItemAccessMode ruleType, IHasId storeItem, IUserInfoStore user)
        {
            var rules = this.GetItemRulesForUser(ruleType, storeItem, user);

            //if no rules are present, default to no access
            if (rules == null || rules.Count == 0)
                return false;

            foreach (var each in rules)
            {
                var res = each.HasAccess(storeItem, user);
                //if it's doesn't have a value the rule is skipped
                if (!res.HasValue)
                {
                    continue;
                }

                return res.Value;
            }

            return false;
        }
 public HasDateLastTouchedDecoration(IHasId decorated, DateTime DateLastTouched)
     : base(decorated)
 {
     this.DateLastTouched = DateLastTouched.ToUniversalTime();
 }
 public ContextualIHasIdDecoration(IHasId decorated, object context)
     : base(decorated)
 {
     this.Context = context;
 }