InstallShield - Condition for Component - components

I am currently struggling with an custom property (defined in VBScript as Custom Action) and the usage as Condition for an Component:
Property = MYDOMAIN
MSI Log entries:
PROPERTY CHANGE: Modifying MYDOMAIN property. Its current value is '0'. Its new value: '999'.
Property(S): SecureCustomProperties = ISFOUNDNEWERPRODUCTVERSION;USERNAME;COMPANYNAME;ISX_SERIALNUM;SUPPORTDIR;INSTALLDIR;MYDOMAIN
MYDOMAIN = 999
The component condition looks like:
MYDOMAIN="999"
The Component is not installed during install process, I made several variations:
MYDOMAIN<<"999"
MYDOMAIN<<999
MYDOMAIN=999
Anybody there who can enlight me what I am doing wrong here?
When no condition is defined the component is being installed.
Cheers
Thomas

Problem solved:
https://community.flexerasoftware.com/showthread.php?138196-component-condition-not-working
Moved the Custom Action with the Property definition to an earlier position within the sequence.
Everything seems to work now :)

Related

Upgrading Automapper and mapping zero to null based based on an attribute

I'm not very familiar with AutoMapper but am trying to update AutoMapper 4 to AutoMapper 10 (last version to support .Net Framework) on a project, and I have run into a problem: The ResolutionContext changed in the 4-5 upgrade so that it no longer has a Parent property.
The existing code works with an attribute that is put on properties in the view model where zero is supposed to be treated as a null, and the existing type converter has this code in it:
var prop = context.Parent.Parent.DestinationType.GetProperty(context.MemberName);
var attributes = prop.GetCustomAttributes(false);
var zeroAttr = attributes.Where(a => a.GetType() == typeof(ZAttribute)).ToList();
But as of AutoMapper 5, ResolutionContext.Parent and ResolutionContext.Member no longer exists.
This allows mapping zero to null for any/all view model, as long as the property has the attribute, there doesn't need to a specific mapping for that type (I think that is how it works). If the attribute isn’t on the property the normal mapping is done (zero stays zero).
How can this be done with AutoMapper 10?
I'm thinking it might be some type of ValueResolver...

Entity Framework Core 3.0: Modify configured Global Query during runtime

I've following requirement:
During the model configuration, I create a QueryFilter for an Entity
var entity = modelBuilder.Entity<TBaseTable>().HasQueryFilter(r => r.UserId == CurrentUserId)
So during runtime in some cases the CurrentUserId changes. But my QueryFilter does not get refreshed. The filter criteria still are working with the old UserId value, which I had during the configuration. How do i modify the my QueryFiler, which was set during the configuration? If I'm right then the whole model is already cached and will not be reinitialized. Any ideas about that?
The trick is to declare CurrentUserId as a property on your DbContext class - the property getter can still return a value from a global class instance.
Global filters can be made dynamic by using properties/methods/fields of the db context. See the TenantId example in Global Query Filters documentation.
(Since I needed to read the comments to find the answer to your question I rephrased the comment as provided by "Ivan Stoev Oct 8 '19 at 15:34" and posted it as an answer)

Use property in OSGI component declaration

In my module, in OSGI component declarationIi need to use a property which will be in my portal-ext.properties, like that :
#Component(
immediate = true,
property = {
"dispatcher=FORWARD",
"dispatcher=REQUEST",
"servlet-context-name=",
"servlet-filter-name=Detail UC Filter",
"url-pattern=/web/guest/" + PropsUtil.get("myPath") + "/*"
}
But i get the compilation error : " The value for annotation attribute Component.property must be a constant expression". How can i do to use a property here?
But i get the compilation error : " The value for annotation attribute Component.property must be a constant expression". How can i do to use a property here?
The entry:
"url-pattern=/web/guest/" + PropsUtil.get("myPath") + "/*"
is the problem. This is because annotations can only have values that are compile-time constants. Obviously this property is not a compile time constant as its value depends on calling a method.
If you want to supply property values at runtime then you can do this in OSGi using Configuration Admin. All Declarative Services components are configurable by default, using a pid which is either:
User configured by setting #Component(configurationPid="foo")
User configured by setting #Component(name="bar")
Defaulted using the fully qualified class name of the component implementation
When you supply a configuration dictionary to Configuration Admin which matches the pid for your DS component then it will be bound to the component.
Your component properties will be merged with the configuration dictionary (with the configuration overriding the static properties). This can be received by your component using an #Activate method
If your component is registered as a service then your service properties will also be updated.
If your component has a #Modified method then these changes will be dynamic, otherwise your component instance will be deactivated and discarded, and a new instance created and activated.
You can force your component not to activate until a configuration has been provided by setting your component's configuration policy. This is useful when you have a property that needs to exist, but can't be known until runtime.
#Component(configurationPolicy=ConfigurationPolicy.REQUIRE)
You can set any of these properties using a config admin configuration.
So one approach is to have a separate component that writes a configuration for this component.
You can use configurationPolicy = ConfigurationPolicy.REQUIRE to prevent the component to become activated before this configuration is present.
Another approach is to use a component factory. See this blog from Scott.

CoreData: warning: Unable to load class named

I am duplicating an existing Objective-C TV Show app to a new Swift version using Xcode 6.1 and am having some issues with CoreData.
I have created a model of 4 entities, created their NSManagedObject subclass (in Swift), and all files have the proper app targets set (for 'Compile Sources').
I am still getting this error whenever I try to insert a new entity:
CoreData: warning: Unable to load class named 'Shows' for entity
'Shows'. Class not found, using default NSManagedObject instead.
A few comments:
When saving to Core Data, I use the parent-child context way to allow background threading. I do this by setting up the ManagedObjectContext using:
lazy var managedObjectContext: NSManagedObjectContext? = {
// Returns the managed object context for the application (which is already bound to the persistent store coordinator for the application.) This property is optional since there are legitimate error conditions that could cause the creation of the context to fail.
let coordinator = self.persistentStoreCoordinator
if coordinator == nil {
return nil
}
var managedObjectContext = NSManagedObjectContext(concurrencyType: NSManagedObjectContextConcurrencyType.MainQueueConcurrencyType)
managedObjectContext.persistentStoreCoordinator = coordinator
return managedObjectContext
}()
and by saving data using:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), { () -> Void in
var context = NSManagedObjectContext(concurrencyType: NSManagedObjectContextConcurrencyType.PrivateQueueConcurrencyType)
context.parentContext = self.managedObjectContext!
...rest of core data saving code here...
})
This warning is one of the quirks we have to deal with while the details of the Swift implementation are being ironed out. The warning occurs spuriously, i.e. your setup might work even if you do not follow the steps outlined below.
I have been able to get rid of it in most cases by making sure that the class is set correctly in the model editor. Unlike in many other SOF posts (including answers to this question), the suggestion to include the module name (like MyApp.Shows) has not helped me.
Make sure you check these three items:
1.
Version that works up to Xcode 7 beta 3
Notice that I corrected your entity name to the more appropriate singular.
Version that works for Swift 2.0 in Xcode 7.1
(Should work for Xcode 7 beta 4 and above)
You need to delete the text "Current Product Module" in Module!
2.
You should also follow the frequent recommendation to include
#objc(Show)
just above your class.
Note: If you are using Xcode 7 beta 4 or later, this step is optional.
3.
Also make sure to cast the created managed object to the proper class, as the default would be just NSManagedObject.
var newShow = NSEntityDescription.insertNewObjectForEntityForName("Show",
inManagedObjectContext: context) as Show
SWIFT 2 / XCODE 7 Update:
This issue (see my April 3 comment on this answer as well) is resolved in Swift 2 and XCode 7 beta release by Apple.
So you actually now do not need #objc(myEntity) in Swift as answered by Mundi or using
"MyAppName." before your Class name. It will stop working. So remove these, just put Class name in File and select Current Working Module as Module
and cheers!
But for those using #objc(myEntity) in Swift (like me), you can use this other solution instead which works smoothly.
In the xcdatamodel correct class in. It should look like this:
Here you go. Module.Class is the pattern for CoreData in Swift and XCode 6. You will also need the same procedure when using Custom Policy class in Model Policy or other CoreData stuff. A note: In image, The Name and Class should be Car and MyAppName.Car (or whatever the name of your entity). Here, User is a typo.
When using Xcode 7 and purely Swift, I actually had to remove #objc(MyClass) from my auto-generated NSManagedObject subclass (generated from Editor > Create NSManagedObject Subclass...).
In Xcode 7 beta 2 (and I believe 1), in the model configuration a new managed object of type File is set to the Module Current Product Module and the class of the object is shown in configuration as .File.
Deleting the module setting so it is blank, or removing the full stop so the class name in configuration is just File are equivalent actions, as each causes the other change. Saving this configuration will remove the error described.
In Xcode 6.1.1 you do not need to add the #objc attribute since the base entity is a subset of an objc class (NSManagedObject) (see Swift Type Compatibility. In CoreData the full Module.Class name is required. Be aware the Module name is what is set in Build Settings -> Packaging -> Product Module Name. By default this is set to $(PRODUCT_NAME:c99extidentifier) which will be the Target's name.
With xCode 7 and Swift 2.0 version, you don't need to add #objc(NameOfClass), just change the entity settings in "Show the Data Model Inspector" tab like below -
Name - "Your Entity Name"
Class - "Your Entity Name"
Module - "Current Product Module"
Code for Entity class file will be like (in my code Entity is Family) -
import UIKit
import CoreData
class Family: NSManagedObject {
#NSManaged var member : AnyObject
}
This example is working fine in my app with xCode 7.0 + swift 2.0
Do not forget to replace PRODUCT_MODULE_NAME with your product module name.
When a new entity is created, you need to go to the Data Model Inspector (last tab) and replace PRODUCT_MODULE_NAME with your module name, or it will result a class not found error when creating the persistent store coordinator.
You also need to use (at least with Xcode 6.3.2) Module.Class when performing your cast for example:
Assuming your module (i.e. product name) is Food and your class is Fruit
let myEntity = NSEntityDescription.entityForName("Fruit", inManagedObjectContext: managedContext)
let fruit = NSManagedObject(entity: myEntity!, insertIntoManagedObjectContext:managedContext) as! Food.Fruit
Recap:
Include module name when defining entity in Data Model Editor (Name: Fruit, Class: Food.Fruit)
When accessing the entity in code (i.e.SWIFT), cast it with Module.class (e.g. Food.Fruit)
I also encountered a similar problem, follow these steps to resolve:
The parent is NSManagedObject, not NSObject
The module of an
entity is default, not "Current Product Module"
Changing the Entity Class name in the Data Model editor to correspond to the class in question and adding #objc(NameOfClass) to file of each NSManagedObject right above the class declaration solved this problem for me during Unit Testing.
Most of these answers still seem to apply in Xcode 14. However, my Swift NSManagedObject subclass is included in a custom framework. So what worked for me is: In that Entity inspector, in that Module field (see screenshot in answer by khunsan), type in the name of your framework, for example, MyFramework.
What worked for me (Xcode 7.4, Swift) is changing the class name to <my actual class name>.<entity name>
in the Entity inspector, 'Class' box.
My initiator of the Managed object subclass, looks like this:
convenience init(<properties to init>) {
let entityDescr = NSEntityDescription.entityForName("<entity class name>", inManagedObjectContext: <managed context>)
self.init(entity: entityDescr!, insertIntoManagedObjectContext: <managed context>)}
//init properties here
For Xcode 11.5: if Codegen property is class Definition, and if you are not getting a suggestion for the entity you created in xcdatamodel. Try to quit Xcode and reopen your project again. It works for me. This answer is only if you are not getting suggestions but if your file doesn't get generated try any above answer.

JsConfig<MyClass>.ExcludePropertyNames example, not working for me

Trying to exclude properties from a model from being included during serialization.
I am using the following syntax:
JsConfig<MyTestClass>.ExcludePropertyNames = new[] { "ShortDescription" };
Just after that I have the following:
return (from o in __someProvider.GetAll() select (new
{
o.Name,
o.ShortDescription
o.InsertDate
}).TranslateTo<MyTestClass>()).ToList()
However once result is returned from the method, it still contains "ShortDescription" field in the Json. Am I doing something wrong?
JsConfig<T>.ExcludePropertyNames appears to be checked only once for each type, in a static constructor for TypeConfig<T>. Thus, if you are configuring ExcludePropertyNames in your service class, just before returning your response, it might be too late -- the TypeConfig properties may already be set up and cached for MyTestClass. I was able to reproduce this.
A more reliable alternative is to move all of your JsConfig<T> configuration to your AppHost setup code.
If you really do need to do this in your service class, e.g. if you are only conditionally excluding property names, then an alternative approach would be to ensure that JsConfig.IncludeNullValues is false (I believe it is by default) and in your service code set ShortDescription to null when appropriate.

Resources