public void TestCacheViaPolicyObjectUsingNameId()
 {
     PolicyLanguageCache.Instance().CurrentLanguage = "en";
     PolicyObject policyObject = new PolicyObject(new Guid(), new Guid("D803727B-5C81-44CC-8BFC-9B68797AC6EB"), false);
     Assert.AreEqual("I am a famous pirate", policyObject.Name);
     PolicyLanguageCache.Instance().CurrentLanguage = "fr";
     Assert.AreEqual("je suis un famoos peer-ate", policyObject.Name);
 }
        public void TestReset()
        {
            PolicyLanguageCache.Instance().CurrentLanguage = "en";
            PolicyObject policyObject = new PolicyObject(new Guid(), new Guid("D803727B-5C81-44CC-8BFC-9B68797AC6EB"), false);
            Assert.AreEqual("I am a famous pirate", policyObject.Name);

            PolicyLanguageCache.Instance().Reset();
            Assert.AreEqual("", policyObject.Name);

            XmlPolicyLanguageStore.Instance().AddLanguage(System.IO.File.ReadAllText(m_testPath + "LanguageEnglish.xml"));

            PolicyLanguageCache.Instance().CurrentLanguage = "en";
            Assert.AreEqual("I am a famous pirate", policyObject.Name);
        }
Esempio n. 3
0
        protected PolicyObject(PolicyObject rhs)
        {
            if (null == rhs)
            {
                Utilities.ErrorMessage errorMessage = new Utilities.ErrorMessage(
                            "INPUT_POLICY_NULL",
                            "Workshare.Policy.Properties.Resources",
                            Assembly.GetExecutingAssembly());
				Logger.LogError(errorMessage.LogString);
				throw new Workshare.Policy.Exceptions.ArgumentNullException("rhs", errorMessage.DisplayString);
            }

            CopyPolicyObject(rhs, false);
            m_readOnly = rhs.ReadOnly;
        }
Esempio n. 4
0
        protected void CopyPolicyObject(PolicyObject rhs, bool createNewId)
        {
            if (null == rhs)
                throw new Workshare.Policy.Exceptions.ArgumentNullException("rhs", "Input policy object is null");

            m_policySetObserver = rhs.m_policySetObserver;

            m_attributes = new Dictionary<string, IPolicyLanguageItem>();
            m_identifier = createNewId ? Guid.NewGuid() : rhs.Identifier;
            Name = (createNewId && rhs.Name != null) ? rhs.Name.Clone() : rhs.Name;

            Dictionary<string, IPolicyLanguageItem>.Enumerator enumer = rhs.m_attributes.GetEnumerator();
            while (enumer.MoveNext())
            {
                IPolicyLanguageItem item = (createNewId && enumer.Current.Value != null) ? enumer.Current.Value.Clone() : enumer.Current.Value;
                m_attributes.Add(enumer.Current.Key, item);
            }
            
            SetLocalContext();
        }
Esempio n. 5
0
 protected PolicyObject(PolicyObject rhs, bool readOnly, bool createNewId)
 {
     CopyPolicyObject(rhs, createNewId);
     m_readOnly = readOnly;
 }
Esempio n. 6
0
        public virtual IPolicyObject DeepCopy(bool readOnly, bool createNewId)
        {
            PolicyObject readOnlyCopy = new PolicyObject();
            readOnlyCopy.CopyPolicyObject(this, createNewId);
            readOnlyCopy.m_readOnly = readOnly;

            if (createNewId)
                readOnlyCopy.CreateNewId();

            return readOnlyCopy;
        }