private static Object GetValueFromContext(DefaultFromContextProperty prop, HarshProvisionerContextBase context) { if (prop.TagType != null) { Logger.Debug( "Property {PropertyName} gets default value form context by the tag type {TagType}", prop.Name, prop.TagType ); return context .GetState(prop.TagType) .Cast<IDefaultFromContextTag>() .FirstOrDefault()? .Value; } if (prop.ResolvedPropertyInfo != null) { Logger.Debug( "Property {PropertyName} resolves objects of type {ResolvedType}", prop.Name, prop.ResolvedPropertyInfo.ResolvedType ); return ContextStateResolveBuilder.Create( prop.ResolvedPropertyInfo.ResolvedType ); } Logger.Debug( "Property {PropertyName} gets default value from context directly by its own type {PropertyType}", prop.Name, prop.PropertyType ); return context .GetState(prop.PropertyType) .FirstOrDefault(); }
private static Object GetValueFromContext(DefaultFromContextProperty prop, HarshProvisionerContextBase context) { if (prop.TagType != null) { Logger.Debug( "Property {PropertyName} gets default value form context by the tag type {TagType}", prop.Name, prop.TagType ); return(context .GetState(prop.TagType) .Cast <IDefaultFromContextTag>() .FirstOrDefault()? .Value); } if (prop.ResolvedPropertyInfo != null) { Logger.Debug( "Property {PropertyName} resolves objects of type {ResolvedType}", prop.Name, prop.ResolvedPropertyInfo.ResolvedType ); return(ContextStateResolveBuilder.Create( prop.ResolvedPropertyInfo.ResolvedType )); } Logger.Debug( "Property {PropertyName} gets default value from context directly by its own type {PropertyType}", prop.Name, prop.PropertyType ); return(context .GetState(prop.PropertyType) .FirstOrDefault()); }