Esempio n. 1
0
 private string GetBaseFileName(string baseFileName)
 {
     if (baseFileName == null || baseFileName.Length == 0)
     {
         return(String.Empty);
     }
     return(ChoPropertyManager.ExpandProperties(this, baseFileName));
 }
        public override IChoProfile ConstructProfile(object target, IChoProfile outerProfile)
        {
            lock (_padLock)
            {
                string message = ChoPropertyManager.ExpandProperties(this, Message);

                return(new ChoBufferProfileEx(Condition, null, message, (ChoBaseProfile)outerProfile, true, null));
            }
        }
        public override IChoProfile ConstructProfile(object target, IChoProfile outerProfile)
        {
            lock (_padLock)
            {
                string message = ChoPropertyManager.ExpandProperties(target, Message);

                return(new ChoProfile(Condition, message));
            }
        }
Esempio n. 4
0
        public override IChoProfile ConstructProfile(object target, IChoProfile outerProfile)
        {
            string message = null;

            if (!String.IsNullOrEmpty(Message))
            {
                message = ChoPropertyManager.ExpandProperties(target, Message);
            }

            return(new ChoBufferProfile(Condition, Name, message, (ChoBaseProfile)outerProfile, false, StartActions, StopActions));
        }
Esempio n. 5
0
        public bool Initialize(bool beforeFieldInit, object state)
        {
            if (beforeFieldInit || String.IsNullOrEmpty(LogDirectory))
            {
                LogDirectory = DefaultLogDirectory;
            }
            else
            {
                LogDirectory = ChoPropertyManager.ExpandProperties(this, LogDirectory);
            }

            if (TurnOn)
            {
                if (!Directory.Exists(LogDirectory))
                {
                    Directory.CreateDirectory(LogDirectory);
                }
            }

            return(false);
        }
Esempio n. 6
0
        //private static void SetAsNotDisposed(IChoProfile profile, bool dispose)
        //{
        //    if (profile == null)
        //        return;

        //    if (profile is ChoBufferProfile)
        //        ((ChoBufferProfile)profile).CanDispose = dispose;
        //    else if (profile is ChoStreamProfile)
        //        ((ChoStreamProfile)profile).CanDispose = dispose;
        //}

        private static string GetProfileName(string name, out MemberInfo memberInfo, out string typeProfileFileName,
                                             out ChoProfileAttribute memberProfileAttribute, out ChoProfileAttribute typeProfileAttribute)
        {
            typeProfileFileName = null;

            StackFrame stackFrame = ChoStackTrace.GetStackFrame(typeof(ChoProfile).Namespace);

            memberInfo = stackFrame.GetMethod();

            memberProfileAttribute = null;
            foreach (ChoProfileAttribute profileAttribute in ChoType.GetMemberAttributesByBaseType <ChoProfileAttribute>(memberInfo))
            {
                if (profileAttribute.Name == name)
                {
                    memberProfileAttribute = profileAttribute;
                    break;
                }
            }

            ChoProfileAttribute emptyTypeProfileAttribute = null;

            typeProfileAttribute = null;
            foreach (ChoProfileAttribute profileAttribute in ChoType.GetAttributes <ChoProfileAttribute>(memberInfo.ReflectedType))
            {
                if (String.IsNullOrEmpty(profileAttribute.Name))
                {
                    emptyTypeProfileAttribute = profileAttribute;
                }
                if (profileAttribute.Name == name)
                {
                    typeProfileAttribute = profileAttribute;
                    break;
                }
            }

            if (typeProfileAttribute == null)
            {
                if (emptyTypeProfileAttribute == null)
                {
                    typeProfileFileName = GLOBAL_PROFILE_NAME;
                }
                else
                {
                    typeProfileFileName = "{0}_{1}_{2}_{3}".FormatString(name.IsNullOrEmpty() ? "Default" : name, "Type", ChoThreadLocalStorage.Target == null ? 0 : ChoThreadLocalStorage.Target.GetHashCode(),
                                                                         ChoPropertyManager.ExpandProperties(ChoThreadLocalStorage.Target, emptyTypeProfileAttribute.Name));
                }
            }
            else
            {
                typeProfileFileName = "{0}_{1}_{2}_{3}".FormatString(name.IsNullOrEmpty() ? "Default" : name, "Type", ChoThreadLocalStorage.Target == null ? 0 : ChoThreadLocalStorage.Target.GetHashCode(),
                                                                     ChoPropertyManager.ExpandProperties(ChoThreadLocalStorage.Target, typeProfileAttribute.Name));
            }

            if (memberProfileAttribute != null)
            {
                return("{0}_{1}_{2}_{3}".FormatString(name.IsNullOrEmpty() ? "Default" : name, memberInfo.Name, ChoThreadLocalStorage.Target == null ? 0 : ChoThreadLocalStorage.Target.GetHashCode(),
                                                      ChoPropertyManager.ExpandProperties(ChoThreadLocalStorage.Target, memberProfileAttribute.Name)));
            }
            else
            {
                return(typeProfileFileName);
            }
        }